[Tutor] is gotchas?
Tim Johnson
tim at johnsons-web.com
Tue Nov 7 01:22:29 CET 2006
* Kent Johnson <kent37 at tds.net> [061106 10:31]:
>
> In [9]: a=[1,2]
>
> In [10]: b=[1,2]
Hmmm! Hmmm!
Lookee here:
## console session
>>> a=[1,2]
>>> b=[1,2]
>>> a is b
False
>>> c='1' ## one byte
>>> d='1' ## one byte
>>> c is d
True
>>> c='1,2'
>>> d='1,2'
>>> c is d
False
The Hmmm! is emmitted because I'm thinking that if everything is an
object in python, then why does `c is d` evaluate to True when
the assigned value is 1 byte and evaluate to False when the assigned
value is more that 1 byte?
I think I ran into this before and that's why I never used `is'.
Good thread. Beats flame wars.
thanks
tim
--
Tim Johnson <tim at johnsons-web.com>
http://www.alaska-internet-solutions.com
More information about the Tutor
mailing list