difference between class statement and def statement (WAS Re: End of file)

Andrew Durdin adurdin at gmail.com
Mon Oct 11 07:25:53 EDT 2004


On Mon, 11 Oct 2004 05:58:03 +0000 (UTC), Steven Bethard 
> 
> The name of a function is bound to the function object when the def statement
> is executed.  However, the function's code block is not executed until f is
> called, at which point the name f has already been bound to the function
> object and is thus available from the globals.

What I wasn't expecting was that "foo" would automatically be looked
up in the enclosing scope... for some reason I'd forgotten about
nested scopes, I don't know why.



More information about the Python-list mailing list