sameness/identity
Markus Schaber
markus at schabi.de
Mon Oct 1 04:44:14 EDT 2001
Hi,
chajadan <python at chajadan.net> schrub:
> I've been watching this thread, and I'm a little confused as to the
> momentum.
>
> As I see it, there are only two qualities of 'sameness': equality and
> identity.
>
> 1 + 2 = 3
>
> 1 plus 2 equals 3
> 1 plus 2 is not 3
>
> Equals just means holds the same value. But nothing can be something
> else. Just equal to it.
>
> If you say 3 is 3, in the sense that there is only one 3 in existance,
> then you are right.
>
> If you add a level of abstraction, and say x = 3 and y = 3, now is
> that 3 and the other 3 the same?
Yes. But x and y are different names.
Just to confuse you some more:
>>> a = 3
>>> b = 3
>>> a is b
1
>>> a = 10000
>>> b = 10000
>>> a is b
0
Identity of python numbers is an implementation detail. For most uses
(concerning numbers), I would recommend to use ==.
markus
--
"The strength of the Constitution lies entirely in the determination of
each citizen to defend it. Only if every single citizen feels duty
bound to do his share in this defense are the constitutional rights
secure." -- Albert Einstein
More information about the Python-list
mailing list