On 9/5/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> 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


No, don't introduce circular dependencies, and make it explicit what your
functions operate on by passing things as parameters, instead of using
global references.

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()


It is *much* more preferable to pass 'storeList' as a parameter to your
functions. Don't change things behind the scenes.

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?


Keep it the way it is. It's wrong on too many levels to do it the other way.

Cheers
> Chris
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to