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
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
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
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
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
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
"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
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
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
"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:/
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
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
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
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:
> 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
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
16 matches
Mail list logo