I try to efficiently iterate over many strings and there is a repeated part of the strings I would like to insert with a partial function
def add_seqs(seqs_outer,sequence):
return seqs_outer[0]+sequence+seqs_outer[1]
def my_function(string,start,stop,list_variable):
seqs_pre=string[:start]
seqs_post=string[stop:]
seqs_outer=(seqs_pre,seqs_post)
seqs_out=map(functools.partial(add_seqs,seqs_outer=seqs_outer),list_variable)
return seqs_out
I finally want to use an apply function over many different strings with a fixed list_variable, but I get an error in my_function:
TypeError: my_function() got multiple values for keyword argument 'seqs_outer'
I guess I do something wrong in the use of partial - how can I make the above code work?
Okay, inspired by this thread I swapped the order of arguments in
def add_seqs(seqs_outer,sequence)
to
def add_seqs(sequence,seqs_outer)
this did the job