Test None for an object that does not implement ==
Roy Smith
roy at panix.com
Sun Dec 25 08:17:28 EST 2011
In article <mailman.4061.1324811442.27778.python-list at python.org>,
Lie Ryan <lie.1296 at gmail.com> wrote:
> Now, whether doing something like that is advisable or not, that's a
> different question; however nothing in python states that you couldn't
> have something that compare equal to None whether there is a bug or not
> in the comparison method.
Just for fun, I tried playing around with subclassing NoneType and
writing an __eq__ for my subclass. Turns out, you can't do that:
Traceback (most recent call last):
File "./none.py", line 5, in <module>
class Nihil(NoneType):
TypeError: Error when calling the metaclass bases
type 'NoneType' is not an acceptable base type
More information about the Python-list
mailing list