I am trying to pass a list of arguments to a function I have created.
def pdftotext(params=[], layout='-layout'):
cmd = ['pdftotext', params, '-layout']
return cmd
This is how I call it:
text = pdftotext(params=['-f', '1', '-l', '2'])
return text
This generates below:
[
"pdftotext",
[
"-f",
"1",
"-l",
"2"
],
"-",
"-layout"
]
However, as you can see, an extra []
is added where the params=[]
are passed.
I have tried converting the params to a string, like:
params = ','.join(params)
But this doesn't work either, as it simply joins each param and separates it with a comma.
How can I pass a set of different parameters to my function, without it creating a double list?