Accessing Module variables from another Module

cjt22 at bath.ac.uk cjt22 at bath.ac.uk
Wed Sep 5 04:38:41 EDT 2007


Hi

I am new to Python (I have come from a large background of Java) and
wondered if someone could explain to me how I can access variables
stored in my main module to other functions within other modules
called
from this module

for example
file: main.py

from Storage import store
from Initialise import init
from ProcessSteps import process

storeList = store()   #Creates a object to store Step objects
init()
process()

file: Initialise.py
def init()
    ......
    storeList.addStep([a,b,c])


file: ProcessSteps.py
def process()
    for step in storeList.stepList:
    etc

I am currently just passing the variable in as a parameter
but I thought with Python there would be a way to gain direct access
to
storeList within the modules called from the top main module?

Cheers
Chris




More information about the Python-list mailing list