Is an interactive command a block?

Ethan Furman ethan at stoneleaf.us
Fri Nov 20 11:02:38 EST 2009


Alf P. Steinbach wrote:
> * Benjamin Kaplan:
>> On Thu, Nov 19, 2009 at 4:42 PM, Alf P. Steinbach <alfps at start.no> wrote:
 >>>
>>> I feel that there's still something lacking in my understanding 
>>> though, like
>>> how/where the "really actually just pure local not also global" is 
>>> defined
>>> for function definition, but it's now just a vague feeling of something
>>> missing, not a feeling of direct contradiction as I had when I believed
>>> local != global.
>>>
>>
>> It's because the only blocks in python that have their own scope are
>> classes and functions. For loops don't have their own scope- they use
>> the enclosing one, which in this case is globals.
> 
> 
> Thanks, but hey, contradiction: you mention globals as an "enclosing" 
> scope, i.e. that a module can have a scope, while stating that only 
> classes and functions have their own scope (so, would a module have it's 
> not own scope?).

module scope == global scope

That is, there is nothing higher than module scope.  (So, yes, global is 
a slight misnomer... in Python it means 'global to a module'.)

~Ethan~



More information about the Python-list mailing list