Re: [Tutor] Need some clarification on this

2011-03-19 Thread Dave Angel
On 01/-10/-28163 02:59 PM, Joel Goldstick wrote: 2011/3/19 Yaşar Arabacı a=5 b=5 a == b True a is b True My question is, why "a is b" is true. What I expected it to be is that, a and b are different things with same value. ___ Tutor maillist -

Re: [Tutor] Need some clarification on this

2011-03-19 Thread Ajit Deshpande
This is a special feature called interning in python. As of Python 2.6, values of -5 to 105 are never cleared from memory for performance reasons. This is applicable to integers only. "==" is a value comparator, whereas "is" is a reference compartor. Check this interesting extension to your code:

Re: [Tutor] Need some clarification on this

2011-03-19 Thread Hugo Arts
2011/3/19 Yaşar Arabacı : a=5 b=5 a == b > True a is b > True > > My question is, why "a is b" is true. What I expected it to be is that, a > and b are different things with same value. > It's an optimization thing. When you type "a=5," the python interpreter is obligated to give y

Re: [Tutor] Need some clarification on this

2011-03-19 Thread xDog Walker
On Saturday 2011 March 19 08:35, Emmanuel Ruellan wrote: > 2011/3/19 Yaşar Arabacı > > > >>>a=5 > > >>>b=5 > > >>>a == b > > > > True > > > > >>>a is b > > > > True > > > > My question is, why "a is b" is true. What I expected it to be is that, a > > and b are different things with same value. > >

Re: [Tutor] Need some clarification on this

2011-03-19 Thread Emmanuel Ruellan
2011/3/19 Yaşar Arabacı > > > >>>a=5 > >>>b=5 > >>>a == b > True > >>>a is b > True > > My question is, why "a is b" is true. What I expected it to be is that, a > and b are different things with same value. > Even stranger: >>> a = 10**10 >>> b = 10**10 >>> a == b True >>> a is b False >>> a =

Re: [Tutor] Need some clarification on this

2011-03-19 Thread Joel Goldstick
2011/3/19 Yaşar Arabacı > >>>a=5 > >>>b=5 > >>>a == b > True > >>>a is b > True > > My question is, why "a is b" is true. What I expected it to be is that, a > and b are different things with same value. > > ___ > Tutor maillist - Tutor@python.org > T

Re: [Tutor] Need some clarification on this

2011-03-19 Thread Joel Goldstick
2011/3/19 Yaşar Arabacı > >>>a=5 > >>>b=5 > >>>a == b > True > >>>a is b > True > > My question is, why "a is b" is true. What I expected it to be is that, a > and b are different things with same value. > > ___ > Tutor maillist - Tutor@python.org > T

[Tutor] Need some clarification on this

2011-03-19 Thread Yaşar Arabacı
>>>a=5 >>>b=5 >>>a == b True >>>a is b True My question is, why "a is b" is true. What I expected it to be is that, a and b are different things with same value. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: h