Re: Strange behaviour of 'is'
- From: Duncan Booth <duncan.booth@xxxxxxxxxxxxxxx>
- Date: 21 Sep 2006 20:35:25 GMT
"Fijoy George" <tofijoy@xxxxxxxxxxx> wrote:
My understanding was that every literal is a constructure of an
object. Thus, the '2.' in 'x = 2.' and the '2.' in 'x is 2.' are
different objects. Therefore, the comparison yields false.
What gave you that idea? The compiler may or may not fold together
identical immutable objects when it compiles your code. In your first
example the comparison is False because the two lines are compiled
separately. If compiled together it might have returned True:
Truex = 2.; x is 2.
However this is purely an implementation detail. The language doesn't
actually require either behaviour.
.
- References:
- Strange behaviour of 'is'
- From: Fijoy George
- Strange behaviour of 'is'
- Prev by Date: Weekly Python Patch/Bug Summary ** REVISED **
- Next by Date: Re: Strange behaviour of 'is'
- Previous by thread: Strange behaviour of 'is'
- Next by thread: Re: Strange behaviour of 'is'
- Index(es):