[issue7796] No way to find out if an object is an instance of a namedtuple

Raymond Hettinger report at bugs.python.org
Tue Feb 23 00:23:03 CET 2010


Raymond Hettinger <rhettinger at users.sourceforge.net> added the comment:

Discussed this with GvR.
Here's a recap:

For 2.6 and 3.1 which are already released, check for the _fields attribute.  This is a guaranteed part of the API is not fragile.  For the C structures, check for the n_fields attribute.

In the future, the C API needs to grow to match the namedtuple() API and we should add an abstract base class describing the common API.  Then you'll be able to write: 
    if isinstance(obj, abc_namedtuple).

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue7796>
_______________________________________


More information about the Python-bugs-list mailing list