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

Peter Waller report at bugs.python.org
Thu Jan 28 01:01:55 CET 2010


Peter Waller <peter.waller at gmail.com> added the comment:

Hi Amaury,

Thanks. I had heard of but never bothered to read about duck-typing before now; though I have used it passively before. I think it does make sense in this case. I can't imagine any case where checking for the _fields attribute would fail and isinstance(x, namedtuple) would not.

Besides which, for my current project I am forced to implement such a "workaround" anyway, so it doesn't affect me as such.

The only reason that remains why I would want it is that I often use isinstance(x, Y) to deal with different Ys, and that was the thing I intuitively wanted to use in this case as a python programmer for quite a few years now. This is probably a pretty weak reason, so I am happy to close this issue if the consensus points to duck typing.

----------

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


More information about the Python-bugs-list mailing list