Namespace question...

oofoe at my-deja.com oofoe at my-deja.com
Thu Nov 4 00:30:19 CET 1999


Hi!

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 foo.py:
------------------------------
Version = '$Id$'

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

main program:
------------------------------
Version = '$Id$'

import foo

foo.bar()

-------------------------------

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

Thanks!

Jos'h


Sent via Deja.com http://www.deja.com/
Before you buy.




More information about the Python-list mailing list