Module variables

Alex aleaxit at yahoo.com
Wed May 28 12:37:01 EDT 2003


"Cameron Zemek" <grom_3 at optusnet.com.au> ha scritto nel messaggio
news:3ed4e018$1 at usenet.per.paradox.net.au...
> Okay I have been translating some pascal into python. I need to have
> variables with module scope. atm I'm doing this with "global" in methods
> that need to update the global variable. Is there a way todo this that
> doesn't need each function to declare what global variables it will need.

Functions must use global statements to identify all global variables they
may re-bind (NOT all those they NEED -- as long as they don't REBIND
them).  Hopefully this makes using global variables painful enough to act
as a discouragement to their use unless it's really the only sensible
thing...;-)

> Also what is the naming convention for variables and functions that are
> internal to the module?

Names meant to be "internal" should start with a single underscore.


Alex







More information about the Python-list mailing list