Re: Question about namespaces and import. How to avoid calling os.system

2005-07-22 Thread Pekka Niiranen
Thanks,

I will analyse these 4 options and select the most suitable
since there are other issues involved too, like
the main.py reads contents of a file to a list that gets
passed to the gen.py with dictionary env_params.
I try to avoid parsing the contents of the file both
in main.py and in gen.py

-pekka-

  Jeff Epler wrote:

 In main.py, execfile(gen.py)
 
 or
 
 In gen.py, have something like
 from __main__ import env_params
 
 or
 
 In main.py, have something like
 import __builtins__; __builtins__.env_params = env_params
 
 or
 
 call a function in the gen.py with env_params as a parameter
 import gen
 gen.do(env_params)
 
 Jeff
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Question about namespaces and import. How to avoid calling os.system

2005-07-22 Thread Jeff Epler
In main.py, execfile(gen.py)

or

In gen.py, have something like
from __main__ import env_params

or

In main.py, have something like
import __builtins__; __builtins__.env_params = env_params

or

call a function in the gen.py with env_params as a parameter
import gen
gen.do(env_params)

Jeff


pgpUfjHyNbbRr.pgp
Description: PGP signature
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Question about namespaces and import. How to avoid calling os.system

2005-07-22 Thread Patricia J. Hawkins
 PN == Pekka Niiranen [EMAIL PROTECTED] writes:

PN Hi there,
PN I have two scripts. The first main.py sets some variables
PN and then imports another called gen.py. The idea is to
PN provide main.py that defines some paths, variables etc.
PN without using Windows environment variables. Various other hackers
PN will make additional Python scripts (subroutines) like gen.py
PN that utilize variables set by the main.py and which main.py calls.
PN I can do this with subprocess module by setting its env -variable
PN but I try to avoid calling shell. How can I merge temporary
PN the namespaces of the two modules?

The built-in execfile should do the trick.

-- 
Patricia J. Hawkins
Hawkins Internet Applications
www.hawkinsia.com
-- 
http://mail.python.org/mailman/listinfo/python-list