Is global really global.
Paul Prescod
paulp at ActiveState.com
Thu Oct 26 21:33:03 EDT 2000
Steve Juranich wrote:
>
> ...
>
> Why is this happenning even though I specified "options" as a global? This
> causes me to suspect that "global" means something different in Python than
> it does in C (which isn't a bad idea).
Global in Python means global to a module.
> Am I misunderstanding the meaning of "global", or is something else afoot?
> How do I work around this? I know using globals isn't good anyway, but I'm
> to the point that I _really_ need to show my professor that I've been doing
> more than sitting on my thumb for the past couple of weeks (read: I need to
> get something done _quickly_).
Put the global in your module, instead of in your main script.
Refer to it as
mymodulename.val = 5 # in your main program
and
val = 5 # in mymodulename
Paul Prescod
More information about the Python-list
mailing list