2009/9/4 Manuel Graune <manuel.gra...@koeln.de>:
> How come the main()-idiom is not "the standard way" of writing a
> python-program (like e.g. in C)?

Speaking for myself, it *is* the standard way to structure a script. I
find it more readable, since I can put my main function at the very
top where it's visible, with the classes and functions it makes use of
following in some logical sequence.

I suspect that this is the case for many real-world scripts. Perhaps
it's mainly in books and demos where the extra stuff is left out so
the reader can focus on what the writer is demonstrating?

> And in addition: Can someone please explain why the first version
> is so much slower?

Access to globals is slower than access to a function's locals.

-- 
Cheers,
Simon B.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to