X is confusing
me at privacy.net
Wed Jul 7 10:21:41 CEST 2004
"Peter Mott" <peter at monicol.co.uk> wrote in
news:40eb114e$0$58816$bed64819 at news.gradwell.net:
> I get this inb the Python interpreter v. 2.3
>>>> X is 99
>>>> Y is 100
> Numbers less that 100 get True, more than 100 get False. It seems.
> What does this mean? If nothing, then why does it happen? I mean how
> do you explain 'is' or 'id(X)' to the first time programmer when it
> does this to you.
Similar things happen with strings:
>>> x = 'hello'
>>> x is 'hello'
>>> y = 'hello world'
>>> y is 'hello world'
The compiler is free to optimise immutable values if it wishes. First time
programmers probably don't need to know all of the details of 'is', for
that matter even experienced programmers rarely need to use it.
More information about the Python-list