Result of ``a is b''
Axel Boldt
axelboldt at yahoo.com
Tue Mar 16 15:55:59 EST 2004
David MacQuigg <dmq at gain.com> wrote
> >>> x = 'akdijfkdienlskfi'
> >>> y = 'akdijfkdienlskfi'
> >>> x is y
> True
> >>> x = 'a b'
> >>> y = 'a b'
> >>> x is y
> False
Wow. So it seems that the action of "is" on immutables is unspecified
and implementation dependent, thus useless to the programmer.
Maybe one could redefine "is" on immutables as follows: for strings
and numbers it acts as "==", for tuples it acts as componentwise "is".
That would be a more useful operator IMHO.
Axel
More information about the Python-list
mailing list