using 'global' across source files.
Mark Jackson
mjackson at wc.eso.mc.xerox.com
Tue Jan 2 09:59:20 EST 2001
Bram Stolk <bram at sara.nl> writes:
> Remco Gerlich wrote:
> > You need "print funcs.val" now (just like you call the function with
> > "funcs.change_val()).
>
> Huh??
> Mind you, 'val' is defined in prog.py, NOT funcs.py.
But the val that change_val changes is defined in funcs.py, NOT prog.py.
> > "global" just means "global inside this module".
>
> Well, that's my whole problem.
> How do I refer to 'val' if it is in another *unnamed* module?
And if you don't name the module, how should Python decide *which* val
you want? There can be one in each namespace, each referring to an
object (which may or may not all be distinct).
> According to the manuals, it should simply be in the namespace
> '__main__', but that doesnt work either.
You're misreading the manuals. Can you tell us how you drew this
conclusion? (Possibly the manuals could be clearer.)
--
Mark Jackson - http://www.alumni.caltech.edu/~mjackson
The power of accurate observation is frequently called
cynicism by those who don't have it.
- George Bernard Shaw
More information about the Python-list
mailing list