explicit variable scoping

David MacQuigg dmq at gain.com
Tue Mar 23 08:38:27 CET 2004


On Mon, 22 Mar 2004 20:48:18 +0000 (UTC), JCM
<joshway_without_spam at myway.com> wrote:

>Sean Ross <sross at connectmail.carleton.ca> wrote:
>
>> "David MacQuigg" <dmq at gain.com> wrote in message
>> news:blbu505vrj35i52ari8a0uivja0pp7a9qu at 4ax.com...
>
>>> If we want to set variables in intermediate scopes, I would prefer a
>>> syntax like:
>>>
>>> b = 1
>>> def f():
>>> a = 2
>>> def g():
>>> global.f.a = 3
>
>Locals inside functions are unique to a function invocation (not the
>function object).  More than one may be active at any given time,
>either through recursion or by creating closures.

Oops.  This could get messy.  Let's not worry about *how* to do
intermediate scopes until we see a good use case for *why* we want to
do it.

-- Dave




More information about the Python-list mailing list