python calling python
Will Ware
wware at world.std.com
Tue Aug 22 12:04:43 EDT 2000
Larry Whitley (ldw at us.ibm.com) wrote:
> How does one call python from python? For example: If the main() in
> myProgram1.py wants to call the main() in myProgram2.py with parameters,
> what incantation should it use?
> I'm trying to use ...
> os.system( "python /myPath/myProgram2.py -myparm1 xxx -myparm2 yyy" )
Rather than bring up two instances of the Python interpreter, why not
just do it within one instance? Try something like this in your
myProgram1.py file:
def main():
# if you'll use myProgram2 goodies elsewhere, put the 'import'
# at the top of your file so it'll be available globally
import myProgram2
myProgram2.main(xxx, yyy)
--
# - - - - - - - - - - - - - - - - - - - - - - - -
# Resistance is futile. Capacitance is efficacious.
# Will Ware email: wware @ world.std.com
More information about the Python-list
mailing list