Scope, type and UnboundLocalError

Paddy paddy3118 at netscape.net
Sun Jul 9 16:42:57 EDT 2006


Dennis Lee Bieber wrote:
> On 9 Jul 2006 11:30:06 -0700, "Paddy" <paddy3118 at netscape.net> declaimed
> the following in comp.lang.python:
>
> > So,
> > An assignment statement may assign an object to a name, in which case
> > the name is 'tagged' as being local,
>
> 	Reverse... Python does not "assign" objects to names... It "assigns"
> names to objects. One object can have multiple names.
>
> 	In the absence of a "global <name>" statement, any unqualified
> <name> found on the left side of an "=" is a local name (the name -- not
> the object it is bound to -- is held as part of the current stack frame
> and is removed on return from the function; the object may or may not be
> garbage collected depending upon any other names bound to it).
>
> 	A qualified name is one with some sort of component specifier:
> <name>.<component>, <name>[<component>]. These access items that are
> inside the object that <name> is bound on. The component access
> basically is a function/method call telling the object itself to change
> the <component> binding, not the top-level <name> binding.
>
Hi Dennis, in the last paragraph you do not state specifically where
the name for the component name is looked for. Do you mean that for
component name accesses,where  the 'base' is not declared gobal, the
'base' name nevertheless is always looked for in the global scope?

(Please excuse my pedantry).




More information about the Python-list mailing list