This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author jdwhitley
Recipients barry, jdwhitley, pitrou, rhettinger, rrenaud, skip.montanaro
Date 2009-03-08.23:13:31
SpamBayes Score 4.6543632e-06
Marked as misclassified No
Message-id <1236554014.64.0.799097078775.issue1818@psf.upfronthosting.co.za>
In-reply-to
Content
Antoine> I don't understand why NamedTupleReader requires the 
Antoine> fieldnames array
Antoine> rather than the namedtuple class itself. If you could pass it
Antoine> the namedtuple class, users could choose whatever namedtuple 
Antoine> subclass with whatever additional methods or behaviour suits
Antoine> them. It would make NamedTupleReader more flexible and more 
Antoine> useful.

The NamedTupleReader does take the namedtuple class as the fieldnames
argument. It can be a namedtuple, a 'fieldnames' array or None. 
If a namedtuple is used as the fieldnames argument, returned rows are
created using ._make from the this namedtuple. Unless I have read your
requirements incorrectly, this is the behaviour you describe.

Given the confusion, I accept that the documentation needs to be improved. 

The NamedTupleReader and Writer were created to follow as closely as
possible the behaviour (and signature) of the DictReader and DictWriter,
with the exception of using namedtuples instead of dicts.
History
Date User Action Args
2009-03-08 23:13:35jdwhitleysetrecipients: + jdwhitley, skip.montanaro, barry, rhettinger, pitrou, rrenaud
2009-03-08 23:13:34jdwhitleysetmessageid: <1236554014.64.0.799097078775.issue1818@psf.upfronthosting.co.za>
2009-03-08 23:13:33jdwhitleylinkissue1818 messages
2009-03-08 23:13:31jdwhitleycreate