why a main() function?

Simon Brunning simon at brunningonline.net
Tue Sep 19 07:46:34 EDT 2006


On 9/19/06, Diez B. Roggisch <deets at nospam.web.de> wrote:

> I totally fail to see why that should be the case - for python as well as
> for C.

If you put your code into a main() function, all the names that it
binds are in the function's local scope, whereas if the code is in the
module's top level, the names are bound to the module's global scope.
Access to locals is somewhat faster than access to globals.

-- 
Cheers,
Simon B,
simon at brunningonline.net,
http://www.brunningonline.net/simon/blog/



More information about the Python-list mailing list