[Python-Dev] Possible small csv.DictReader change

skip at pobox.com skip at pobox.com
Sun Jul 27 05:21:07 CEST 2008


A new issue in the tracker:

    http://bugs.python.org/issue3436

points out that the csv module's DictReader class doesn't know the
fieldnames defined in the file until you've fetched the first row of data.
It's fairly easy to change the behavior so that __init__ automatically grabs
the fieldnames if they aren't passed into it (I attached a patch) but
Raymond commented that __init__() shouldn't read any line(s) from the file,
instead preferring a separate method to set the fieldnames attribute.

There's the issue though of whether __init__() should implicitly read the
fieldnames from the file or if that task should be delegated to a separate
method which must be called either by the user or from the next() method.
If you have an opinion either way, I'd appreciate it if you added a comment
to that issue.

Regardless which way this issue plays out, is it something that can be put
into 2.6 & 3.0 or does it need to wait at this point?

Thanks,

Skip


More information about the Python-Dev mailing list