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 Isaac Morland
Recipients Isaac Morland
Date 2017-07-31.01:05:52
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
I would like to have the possibility of creating a namedtuple type without explicitly giving it a name.  I see two major use cases for this:

1) Automatic creation of namedtuples for things like CSV files with headers (see #1818) or SQL results (see #13299).  In this case at the point of calling namedtuple I have column headings (or otherwise automatically-determined attribute names), but there probably isn't a specific class name that makes sense to use.

2) Subclassing from a namedtuple invocation; I obviously need to name my subclass, but the name passed to the namedtuple invocation is essentially useless.

My idea is to allow giving None for the typename parameter of namedtuple, like this:

class MyCustomBehaviourNamedtuple (namedtuple (None, ['a', 'b'])):

In this case namedtuple will generate a name based on the field names.

This should be backward compatible because right now passing None raises a TypeError.  So there is no change if a non-None typename is passed, and an exception is replaced by computing a default typename if None is passed.

Patch to follow.
Date User Action Args
2017-07-31 01:05:54Isaac Morlandsetrecipients: + Isaac Morland
2017-07-31 01:05:54Isaac Morlandsetmessageid: <>
2017-07-31 01:05:54Isaac Morlandlinkissue31085 messages
2017-07-31 01:05:52Isaac Morlandcreate