why a main() function?

Fredrik Lundh fredrik at pythonware.com
Tue Sep 19 11:05:04 EDT 2006


Diez B. Roggisch wrote:

> Interesting. How is the index computed? I would have assumed that locals()
> is somehow used, which is a dicht.
> 
> I can imagine enumerating left-hand-side names and trying to replace their
> occurence with the index, falling back to the name if that is not
> possible/the index isn't found. Does that come close?

yes, but there is no fallback: if a name inside a function is local or 
not is decided once and for all by the compiler, using static analysis.
see:

     http://pyref.infogami.com/naming-and-binding

</F>




More information about the Python-list mailing list