[Python-Dev] Namespaces

Aahz aahz@pythoncraft.com
Fri, 5 Apr 2002 19:47:06 -0500

[After going away and thinking about this for a few days...]

On Tue, Apr 02, 2002, Martin v. Loewis wrote:
> 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.

You're right, though I think I prefer "computed binding" to "computed
attribute" (assuming you're referring to the __getitem__ / __setitem__
protocol).  The question I'm now wrestling with is what to call
bindings in general.  I'm tripping over this:

    Rebinding a <foo> does not affect the originally bound object
    (unless the originally bound object's reference count goes to zero).

Any ideas about what to call <foo>?  (Calling it a binding sounds a
little too self-referential.)

> 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).

Exactly.  Binding operations are different from binding lookups.  I'm
not sure I understand your unless, though; can you demonstrate with
Aahz (aahz@pythoncraft.com)           <*>         http://www.pythoncraft.com/

"There are times when effort is important and necessary, but this should
not be taken as any kind of moral imperative."  --jdecker