list comprehension problem

alex23 wuwei23 at
Fri Oct 30 05:05:02 CET 2009

On Oct 30, 1:10 pm, Nick Stinemates <n... at> wrote:
> > Some objects are singletons, ie there's only ever one of them. The most
> > common singleton is None. In virtually every other case you should be
> > using "==" and "!=".
> Please correct me if I am wrong, but I believe you meant to say some
> objects are immutable, in which case you would be correct.

You're completely wrong. Immutability has nothing to do with identity,
which is what 'is' is testing for:

>>> t1 = (1,2,3) # an immutable object
>>> t2 = (1,2,3) # another immutable object
>>> t1 is t2
>>> t1 == t2

MRAB was refering to the singleton pattern[1], of which None is the
predominant example in Python. None is _always_ None, as it's always
the same object.


More information about the Python-list mailing list