On Fri, Apr 27, 2012 at 12:00 AM, Adam Skutt <ask...@gmail.com> wrote: > C# and Python do have a misfeature: '==' is identity comparison only > if operator== / __eq__ is not overloaded. Identity comparison and > value comparison are disjoint operations, so it's entirely > inappropriate to combine them.
So what should happen if you don't implement __eq__? Should the == operator throw an exception? This can be done fairly easily: class object(object): def __eq__(self,other): raise NoYouDontException("Naughty programmer, mustn't do that!") (Works only if you always explicitly subclass object, even though that's not necessary in Python 3.) ChrisA -- http://mail.python.org/mailman/listinfo/python-list