Result of ``a is b''

Robert Brewer fumanchu at amor.org
Tue Mar 16 21:52:41 EST 2004


Andrew Koenig wrote:
> "Axel Boldt" <axelboldt at yahoo.com> wrote in message
> news:40200384.0403161255.7fca7a8c at posting.google.com...
> 
> > Wow. So it seems that the action of "is" on immutables is 
> unspecified
> > and implementation dependent, thus useless to the programmer.
> 
> Hardly.  It has two fundamental properties, which can 
> sometimes be useful:
> 
>     1) If x and y refer to the same object, "x is y" yields True.
> 
>     2) If "x is y" yields True, "x==y" also yields True.  
> Equivalently, if
> "x==y" yields False, "x is y" also yields False.

Assuming nobody has overridden __eq__, of course. ;)


FuManChu




More information about the Python-list mailing list