Project-wide variable...

Gnarlodious gnarlodious at gmail.com
Fri Jun 24 07:30:23 EDT 2011


On Jun 24, 12:27 am, Terry Reedy wrote:

> > 1) Can I tell Executable.py to share Data with ModuleTest.py?
>
> After the import is complete, yes.
> import ModuleTest
> ModuleTest.Data = Data
>
> This works if the use of Data is inside a function that is not called
> during import, not if the use of Data is at toplevel or in a class
> statement outside a def.

That works! The solution looks like this:

# controlling program:
from Module import Data
import ModuleTest
ModuleTest.Data = Data
ModuleTest.getData()

# module:
def getData():
    print(Data.Plist.Structure)


Thanks for all your help!

-- Gnarlie



More information about the Python-list mailing list