Namespace question...

oofoe at oofoe at
Thu Nov 4 00:30:19 CET 1999


How can you access the global namespace in python 1.5.1? I'd like to get
a version string which is declared in the main script file. However,
each module also has a version string which overrides the original one.
I tried to access it as __main__.Version, similarly to $main::Version in
Perl, which is what I'm more familiar with. Of course, it didn't work.

I have something like this:

module file
Version = '$Id$'

def bar():
   print "Version is: ", __main__.Version

main program:
Version = '$Id$'

import foo


I'd certainly appreciate any pointers. The namespace stuff seems to get
a little hazy around issues like this.



Sent via
Before you buy.

More information about the Python-list mailing list