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

Peter Waller report at bugs.python.org
Wed Jan 27 17:11:09 CET 2010


New submission from Peter Waller <peter.waller at gmail.com>:

Apologies if there is a way of doing this, but I haven't been able to find anything.

I need to be able to do the following:

my_tuple = namedtuple("my_tuple", "a b c")
obj = my_tuple(1,2,3)

if isinstance(obj, namedtuple):
    .. do stuff ..

The best I could come up with for the moment is:

if isinstance(obj, tuple) and type(obj) is not tuple:
    .. do stuff ..

----------
messages: 98437
nosy: pwaller
severity: normal
status: open
title: No way to find out if an object is an instance of a namedtuple
versions: Python 2.6

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


More information about the New-bugs-announce mailing list