On Sun, Dec 25, 2011 at 2:38 AM, Nobody <nob...@nowhere.com> wrote: > On Sat, 24 Dec 2011 23:09:50 -0800, GZ wrote: > >> I run into a weird problem. I have a piece of code that looks like the >> following: >> >> f(...., a=None, c=None): >> assert (a==None)==(c==None) >> >> >> The problem is that == is not implemented sometimes for values in a >> and c, causing an exception NotImplementedError. > > I have no idea how that can happen. If a.__eq__(None) returns > NotImplemented, the interpreter should flip the test and perform the > equivalent of None.__eq__(a), which will return False.
Maybe the class has a misbehaved __eq__ that raises NotImplementedError directly instead of returning NotImplemented. -- http://mail.python.org/mailman/listinfo/python-list