csv documentation error? (was Re: csv - howto specify fmtparam parameters)

Peter Otten __peter__ at web.de
Thu Aug 21 12:21:37 CEST 2003


Helmut Jarausch wrote:

> still I am curious: is the documentation in error?

Taken directly from csv.py:

class DictReader:
    def __init__(self, f, fieldnames, restkey=None, restval=None,
                 dialect="excel", *args):
        self.fieldnames = fieldnames    # list of keys for the dict
        self.restkey = restkey          # key to catch long rows
        self.restval = restval          # default value for short rows
        self.reader = reader(f, dialect, *args)

As there is no provision for keyword arguments in DictReader.__init__() as
opposed to reader, it seems to be a bug that can be easily fixed:

class DictReader:
    def __init__(self, f, fieldnames, restkey=None, restval=None,
                 dialect="excel", *args, **kwd):
        self.fieldnames = fieldnames    # list of keys for the dict
        self.restkey = restkey          # key to catch long rows
        self.restval = restval          # default value for short rows
        self.reader = reader(f, dialect, *args, **kwd)

Peter




More information about the Python-list mailing list