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

Éric Araujo report at bugs.python.org
Wed Jan 27 17:16:31 CET 2010


Éric Araujo <merwok at netwok.org> added the comment:

Hello

namedtuple is a factory function, not a class (as hinted by the naming in lower case, see PEP 8), so there are no instances of namedtuple.

You can workaround that with issubclass, or checking for special namedtuples attributes (_asdict, _replace, but this is fragile), or just not use class cheking, often unneeded in Python code.

Kind regards

----------
nosy: +Merwok

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


More information about the Python-bugs-list mailing list