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 - Sybren's explanation
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 expected result:
a = b =
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 expected result:
a = b =
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
code and got the expected
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 argue that
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
Python 2.4.1 (#2, May 5
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
Python also needs to
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
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 = [1, 2, 3]
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
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 this
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 (dictionary
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 variable, not the
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
--
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
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,
you really have to
16 matches
Mail list logo