[Python-Dev] Namespaces (original) (raw)

Martin v. Loewis martin@v.loewis.de
02 Apr 2002 01:13:26 +0200


Aahz <aahz@pythoncraft.com> writes:

I'm fine with "local scope" and "object attributes" to disambiguate them; I just think it's important that people understand that a name is a name is a name, and all names live in some namespace.

That isn't really true: a computed attribute lives in no namespace, instead, some function is invoked to determine the attribute value.

Furthermore, some attributes live in multiple namespaces. Given

obj.name

what namespace is considered to find the name? NOT the namespace of obj, alone - Python also considers the namespace of obj's class (if obj is an instance), of the base classes, etc. OTOH,

obj.name = None

modifies the namespace of obj (unless name is a computed attribute).

Regards, Martin