On 2006-08-09 07:54:22, Slawomir Nowaczyk wrote: > But I do not believe there is any "identity of a variable" > which corresponds to "id()". Still, you used such term -- repeatedly. > > I do not know what do you mean by it.
In C, the "identity" of anything is usually the memory location. Same location means "same thing", different location means "different thing". Python is a few levels above this almost hardware level. So while the memory thing in the end still holds for Python also, it has other means above that (and I'm not sure it even allows native access to the raw memory access). So if you want to know whether two Python variables refer to the same object, you get the id() of them; same id() means they refer to the same object. If you want to know whether two C variables (not necessarily pointers, I mean variables) refer to the same memory location, you get their addresses. Same address means they refer to the same memory location. Since the identity of a variable is not a defined concept in C, it can only be a (subjective) approximation. I feel that the address of a variable reflects most closely what I would see as its identity in C. But that's subjective, of course. Gerhard -- http://mail.python.org/mailman/listinfo/python-list