"Stef Mientki" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]

> Is there a way to run the initialization code from a script(file) once,
> to achieve the same effect ?

Certainly. This is what Python modules are all about. You should probably
read up on those a bit here: http://docs.python.org/tut/node8.html

But briefly, probably what you want to do is put some code in a file, say
init.py:

    # init.py
    X = 3
    Y = 5
    # A bunch of other stuff


And then in your main program, execute

    from init import *

That will take all the module-scoped variables defined in init.py and place
them in the namespace of the import statement (whcih could be global, the
interactive interpreter, or otherwise)

See also the 'global' statement as it relates to modifying global variables
in an inner scope.

Good luck,
-ej


-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to