Strict comparisons in Python 2
Steven D'Aprano
steve at pearwood.info
Tue Oct 13 09:43:54 EDT 2015
In Python 3, comparisons between arbitrary types raise TypeError:
py> None < 2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unorderable types: NoneType() < int()
In Python 2, that same comparison will arbitrarily return True or False,
according to some implementation-dependent rule.
Is there some way to force the Python 3 rules into Python 2? Something like
a __future__ import?
--
Steven
More information about the Python-list
mailing list