namespace question

Fredrik Lundh fredrik at pythonware.com
Wed Apr 19 05:50:06 EDT 2006


"Nugent, Pete (P.)" wrote:

> I'm confused by namespaces in python, specifically
> using the global keyword.  I'm able to access and
> modify a global variable from a function if the function
> is defined in the same module but not if the function
> s defined in a different module:

"global" means "not local", not "application-wide global".

> Can anyone tell me how I can modify the test_var variable
> form another module?

    import t2
    t2.test_variable = some value

also see:

    http://pyfaq.infogami.com/how-do-i-share-global-variables-across-modules
    http://pyfaq.infogami.com/what-are-the-rules-for-local-and-global-variables-in-python

</F>






More information about the Python-list mailing list