I am having trouble figuring out the arguments to csv.dictreader and realized I have no clue what the square brackets signify.
From the docmentation:
class csv.DictReader(csvfile[, fieldnames=None[, restkey=None[, restval=None[, dialect='excel'[, *args, **kwds]]]]])
I’d appreciate a summary of the arguments to the class instantiation.
Thanks
The square brackets indicate that these arguments are optional. You can leave them out.
So, in this case you are only required to pass the
csvfileargument tocsv.DictReader. If you would pass a second parameter, it would be interpreted as thefieldnamesarguments. The third would berestkey, etc.If you only want to specify e.g.
cvsfileanddialect, then you’ll have to name the keyword argument explicitly, like so:For more on keyword arguments, see section 4.7.2 of the tutorial at python.org.