Is it possible to create C-style "main" function in Python? (for teaching purposes)

alex23 wuwei23 at gmail.com
Tue Oct 4 00:27:12 EDT 2011


rantingrick <rantingr... at gmail.com> wrote:
> Why? Well because many times i find myself wondering if this or that
> variable is local or global -- and when i say "global" i am speaking
> of module scope! The "global<DOT>" cures the ill.

Given your stated propensity for huge code blocks not chunked into
functions, I'm not surprised you lose track of what is global, what is
nonlocal etc. This is another clear advantage of small functions: you
can view it all at once. For the rest of us, a variable is global if
its referenced but not defined in a specific scope. There's no need
for such verbose hand-holding.

I'd say the wart is in your design practice rather than the language
itself.



More information about the Python-list mailing list