Class Variable Access and Assignment

Steven D'Aprano steve at REMOVETHIScyber.com.au
Thu Nov 3 16:47:10 CET 2005


On Thu, 03 Nov 2005 14:27:48 +0100, Sybren Stuvel wrote:

> Antoon Pardon enlightened us with:
>> I would expect a result consistent with the fact that both times b.a
>> would refer to the same object.
> 
> "b.a" is just a name, not a pointer to a spot in memory. Getting the
> value associated with that name is something different from assigning
> a new value to that name.

You've got the right concept, but not the right terminology. The "b"
before the dot is a name. The "a" after the dot is a name. But the whole
thing together is not a name: b.a is an attribute reference. You wouldn't
call b["a"] a name, and you shouldn't call b.a a name either.


-- 
Steven.




More information about the Python-list mailing list