Interesting behaviour of the assignment
Neelakantan Krishnaswami
neelk at alum.mit.edu
Sat Dec 30 09:32:57 EST 2000
More information about the Python-list mailing list
Sat Dec 30 09:32:57 EST 2000
- Previous message (by thread): Interesting behaviour of the assignment
- Next message (by thread): Interesting behaviour of the assignment
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Fri, 29 Dec 2000 09:07:21 +0200 (IST), Moshe Zadka wrote: >On Thu, 28 Dec 2000, "Alex Martelli" <aleaxit at yahoo.com> wrote: > >> (Actually, in the case of None, the semantics of is and >> == are identical, but 'is' can be a tiny little bit faster). > >No. > >>>> class FoolAlex: >... def __cmp__(self, other): >... return cmp(None, other) >... >>>> FoolAlex() == None >1 >>>> FoolAlex() is None >0 > > Which is why, in code I write, I always use "x is None" -- faster > and more reliable. Oddly enough, this is why I always use '=='. I figure that if the class's author wanted the object to test the same as None, he or she had a good reason. :) Neel
- Previous message (by thread): Interesting behaviour of the assignment
- Next message (by thread): Interesting behaviour of the assignment
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list