Nested scopes hitch

Duncan Booth duncan at NOSPAMrcp.co.uk
Tue Apr 9 04:16:22 EDT 2002


weeks at vitus.scs.agilent.com (Greg Weeks) wrote in
news:1018303417.472398 at cswreg.cos.agilent.com: 

> I don't have the documentation or a Python 2.1 handy.  But I did
> originally copy from the documentation the text:
> 
>     Names in class scope are not accessible.
> 
>     Under this proposal, it will not be possible to gain
>     dictionary-style access to all visible scopes.
> 
> My interpretation of this is that visible bindings from an
> intermediate scope will be in neither globals() nor locals().

I must admit I didn't read the documentation, I just checked it out by 
defining a function that accessed a nested scope variable and printed out 
locals() and globals(). This was under 2.2 BTW.
I don't see why locals() shouldn't include the nested scope variables, 
after all they are all known at compile time just like local vars.

-- 
Duncan Booth                                             duncan at rcp.co.uk
int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3"
"\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure?



More information about the Python-list mailing list