Re: what is the keyword "is" for?

2006-08-16 Thread Alex Martelli
Sybren Stuvel <[EMAIL PROTECTED]> wrote: > Dan Bishop enlightened us with: > a = b = 1e1000 / 1e1000 > a is b > > True > a == b > > False > > If "a is b" then they refer to the same object, hence a == b. It > cannot be otherwise, unless Python starts to defy logic. I copied your P

Re: what is the keyword "is" for?

2006-08-16 Thread Sion Arrowsmith
Simon Forman <[EMAIL PROTECTED]> wrote: >Python 2.4.3 (#2, Apr 27 2006, 14:43:58) >[GCC 4.0.3 (Ubuntu 4.0.3-1ubuntu5)] on linux2 >Type "help", "copyright", "credits" or "license" for more information. > >|>> a = b = 1e1000 / 1e1000 >|>> a is b >True >|>> a == b >False I agree with you: $ python P

Re: what is the keyword "is" for?

2006-08-16 Thread Dan Sommers
On Wed, 16 Aug 2006 10:06:03 +0200, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > In [14]: a is b > Out[14]: True > In [15]: a == b > Out[15]: False > In [16]: a > Out[16]: nan > On my platform the division results in "Not A Number". Two NaNs > compared are always `False`. You could a

Re: what is the keyword "is" for?

2006-08-16 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Sybren Stuvel wrote: > Dan Bishop enlightened us with: > a = b = 1e1000 / 1e1000 > a is b >> True > a == b >> False > > If "a is b" then they refer to the same object, hence a == b. It > cannot be otherwise, unless Python starts to defy logic. I copied your > c

Re: what is the keyword "is" for?

2006-08-16 Thread Simon Forman
Sybren Stuvel wrote: > Dan Bishop enlightened us with: > a = b = 1e1000 / 1e1000 > a is b > > True > a == b > > False > > If "a is b" then they refer to the same object, hence a == b. It > cannot be otherwise, unless Python starts to defy logic. I copied your > code and got the expec

Re: what is the keyword "is" for?

2006-08-16 Thread [EMAIL PROTECTED]
Sybren Stuvel wrote: > Dan Bishop enlightened us with: > a = b = 1e1000 / 1e1000 > a is b > > True > a == b > > False > > If "a is b" then they refer to the same object, hence a == b. It > cannot be otherwise, unless Python starts to defy logic. I copied your > code and got the expec

Re: what is the keyword "is" for?

2006-08-16 Thread Hendrik van Rooyen
"Dan Bishop" <[EMAIL PROTECTED]> wrote: | Sybren Stuvel wrote [on the difference between is and ==]: | > Obviously "a is b" implies "a == b", | | Not necessarily. | | >>> a = b = 1e1000 / 1e1000 | >>> a is b | True | >>> a == b | False Huh? - wtf is this - I find this deeply disturbing - Sybre

Re: what is the keyword "is" for?

2006-08-15 Thread Dan Bishop
Steve Holden wrote: > daniel wrote: > > Martin v. Löwis wrote: > [...] > >>For some objects, "change the object" is impossible. If you have > >> > >>a = b = 3 > >> > >>then there is no way to change the object 3 to become 4 (say); > >>integer objects are "immutable". So for these, to make a change

Re: what is the keyword "is" for?

2006-08-15 Thread Dan Bishop
Sybren Stuvel wrote [on the difference between is and ==]: > Obviously "a is b" implies "a == b", Not necessarily. >>> a = b = 1e1000 / 1e1000 >>> a is b True >>> a == b False -- http://mail.python.org/mailman/listinfo/python-list

Re: what is the keyword "is" for?

2006-08-15 Thread Terry Reedy
"Sybren Stuvel" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > 'is' compares the object's addresses. It actually compares the objects' integer identifiers. That happens to be the linear memory address for CPython, but not necesarily so for other interpreters. tjr -- http:/

Re: what is the keyword "is" for?

2006-08-15 Thread Steve Holden
daniel wrote: > Martin v. Löwis wrote: [...] >>For some objects, "change the object" is impossible. If you have >> >>a = b = 3 >> >>then there is no way to change the object 3 to become 4 (say); >>integer objects are "immutable". So for these, to make a change, >>you really have to change the varia

Re: what is the keyword "is" for?

2006-08-15 Thread daniel
Martin v. Löwis wrote: > daniel wrote: > > when I tried to check the stuff out, found sth interesting that if you > > define variables in a style like this: > > a = b = ['a', 'b'] > > changing one list affects the other, and they still refer to same > > object. in fact, seems all compound types (d

Re: what is the keyword "is" for?

2006-08-15 Thread Martin v. Löwis
daniel wrote: > when I tried to check the stuff out, found sth interesting that if you > define variables in a style like this: > a = b = ['a', 'b'] > changing one list affects the other, and they still refer to same > object. in fact, seems all compound types (dictionary for instance) > behave in

Re: what is the keyword "is" for?

2006-08-15 Thread daniel
many thanks to Sybren and Kirk for your helpful explanation. when I tried to check the stuff out, found sth interesting that if you define variables in a style like this: a = b = ['a', 'b'] changing one list affects the other, and they still refer to same object. in fact, seems all compound types

Re: what is the keyword "is" for?

2006-08-15 Thread Kirk McDonald
daniel wrote: > I'm so confused by the keyword "is" and "==" equal sign, it seems they > could be exchanged in some contexts, but not in others, what's the > difference between them in terms of comparation? > > thanks... > > daniel > 'is' compares object identity. == compares values. >>> a

what is the keyword "is" for?

2006-08-15 Thread daniel
I'm so confused by the keyword "is" and "==" equal sign, it seems they could be exchanged in some contexts, but not in others, what's the difference between them in terms of comparation? thanks... daniel -- http://mail.python.org/mailman/listinfo/python-list