Need help with Python scoping rules

Bruno Desthuilliers bruno.42.desthuilliers at websiteburo.invalid
Fri Aug 28 10:41:51 CEST 2009


kj a écrit :
> In <4a967b2f$0$19301$426a74cc at news.free.fr> Bruno Desthuilliers <bruno.42.desthuilliers at websiteburo.invalid> writes:
> 
>> The only thing one is entitled to expect when learning a new language is 
>> that the language's implementation follows the language specs.
> 
> In fact, the official docs, when they discuss scopes, are off to
> a bad start:
> 
>   Names refer to objects. Names are introduced by name binding
>   operations. Each occurrence of a name in the program text refers
>   to the binding of that name established in the innermost function
>   block containing the use.
> 
> The first paragraph implies that binding can only occur within
> functions, which is either incorrect, or presupposes a definition
> of "function" that is not what most programmers would recognize.

Indeed, and you're right to point it. I strongly suggest you submit a 
ticket to the doc maintainers.

> In general, I found the docs very unclear on the subject of scoping.
> PEP 227 is much better, but I wouldn't have thought of it as "the
> specs".

Well, here again, it sure would help to make clear that peps (and 
release specific "what's new") *are* part of the doc. But for sure, what 
used to be a simple and clear reference is now a bit of a mess, despite 
the hard work of the doc team. Side-effect of the rapid growth of the 
language I guess...





More information about the Python-list mailing list