Namespace question...

Aahz Maruch aahz at
Thu Nov 11 04:02:24 CET 1999

In article <80c3e4$vpq$1 at>,  <raptor_99_uk at> wrote:
>In article <7vqgib$l8v$1 at>,
>  oofoe at wrote:
>> 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.
>just declare Version to be global inside bar() as
>def bar():
>    global Version
>    print "Version is: ", Version

Your response is wrong: it works within a module, but not inside a
module that has been imported into another script.  Eric Jacobs gave a
correct response (import __main__), but in general it's a better idea to
pass information in (interface specified) rather than having a module
make assumptions about what kind of script will import it.
                      --- Aahz (

Androgynous poly kinky vanilla queer het    <*>
Hugs and backrubs -- I break Rule 6  (if you want to know, do some research)

More information about the Python-list mailing list