[issue4296] Python assumes identity implies equivalence; contradicts NaN

Christian Heimes report at bugs.python.org
Tue Nov 11 21:45:42 CET 2008

Christian Heimes <lists at cheimes.de> added the comment:

(Comment for Michael, everybody else can safely ignore it.

Instead of writing:
    if isinstance(x, list) or isinstance(x, tuple) or isinstance(x, set):

you can write:
    if isinstance(x, (list, tuple, set)):

or even better:
    if hasattr(x, "__iter__"):

Starting with Python 2.6 you can use "from math import isnan", too.

Python tracker <report at bugs.python.org>

More information about the Python-bugs-list mailing list