The function record() in the pyshp module expects a sequence as input:
outfile.record('First','Second','Third')
What I have is a list:
row = ['First','Second','Third']
When I call the record() function like this:
outfile.record(row)
I get a tuple index out of range error. It turns out the function receives
(['First','Second','Third'],)
How do I call record correctly?
I have tried
outfile.record((row[i] for i in range(len(row)))
but that doesn’t work either.
This will unpack a sequence into individual arguments. This is a formal description of this syntax from the language reference, and this is an informal description from the tutorial.
Note there is a similar construct which will unpack a mapping (dict) into keyword arguments: