Is it possible to create C-style "main" function in Python? (for teaching purposes)
Westley Martínez
anikom15 at gmail.com
Thu Oct 6 00:26:49 EDT 2011
On Thu, Oct 06, 2011 at 02:44:33PM +1100, Cameron Simpson wrote:
> On 03Oct2011 13:10, rantingrick <rantingrick at gmail.com> wrote:
> | Also for scoping.
> |
> | py> count = 0
> | py> def foo():
> | ... global.count += 1
> | py> print count
> | 1
> |
> | 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.
>
> I must admit I rarely have this concern. My own module globals are
> almost entirely CONSTANT type names. (Excluding function and class
> names.)
>
> What's the common ambifuity case for you?
I never have this concern either. Python's functions and classes are
powerful enough to avoid globals entirely. In C I have a few sometimes
and in Fortran and the like they're everywhere. Global variables are
POWERFUL and USEFUL but there's a certain paradigm that goes with them,
and Python works better with an object-oriented w/ functional elements
approach.
More information about the Python-list
mailing list