why () is () and [] is [] work in other way?

Thomas Rachel nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915 at spamschutz.glglgl.de
Wed Apr 25 07:42:31 EDT 2012


Am 24.04.2012 15:25 schrieb rusi:

> Identity, sameness, equality and the verb to be are all about the same
> concept(s) and their definitions are *intrinsically* circular; see
> http://plato.stanford.edu/entries/identity/#2

Mybe in real life language. In programming and mathematics there are 
several forms of equality, where identity (≡) is stronger than equality (=).

Two objects can be equal (=) without being identical (≡), but not the 
other way.

As the ≡ is quite hard to type, programming languages tend to use other 
operators for this.

E.g., in C, you can have

int a;
int b;
a = 4;
b = 4;

Here a and b are equal, but not identical. One can be changed without 
changing the other.

With

int x;
int *a=&x, *b=&x;

*a and *b are identical, as they point to the same location.

*a = 4 results in *b becoming 4 as well.


In Python, you can have the situations described here as well.

You can have a list and bind it to 2 names, or you can take 2 lists and 
bind them to that name.

a = [3]
b = [3]

Here a == b is True, while a is b results in False.


Thomas


>
> And the seeming simplicity of the circular definitions hide the actual
> complexity of 'to be'
> for python:  http://docs.python.org/reference/expressions.html#id26
> (footnote 7)
> for math/philosophy: http://www.math.harvard.edu/~mazur/preprints/when_is_one.pdf




More information about the Python-list mailing list