Result of ``a is b''
Asun Friere
afriere at yahoo.co.uk
Thu Mar 18 01:42:09 CET 2004
"Andrew Koenig" <ark at acm.org> wrote in message news:<Uo%5c.40111$H44.732208 at bgtnsc04-news.ops.worldnet.att.net>...
> "Robert Brewer" <fumanchu at amor.org> wrote in message
> news:mailman.67.1079492061.742.python-list at python.org...
> 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. ;)
>
> Indeed -- if == is redefined so as not to be an equivalence relation, all
> bets are off.
In fact __eq__ can be redefined even /so as to be an equivalence
relation/ such that x==y => True and x is y => False. The
'fundamental properties' posisted, are simply not fundamental.
More information about the Python-list
mailing list