Executing a python script with arguments from a python script

James Stroud jstroud at mbi.ucla.edu
Mon Dec 12 18:36:33 EST 2005


olaufr at gmail.com wrote:
> Hi,
> 
> I need to call a python script, with command line arguments (it is an
> autonomous script with a __main__), from within another python script.
> Can I use exec() or execfile() for this? How to pass the arguments?
> 
> Thanks,
> 
> Olivier.
> 

Obligatory "ugh."

Are you sure you want to do that? Just make the part you want to execute into a 
function and then import it as a module. You will thank me later.

To reluctantly answer your question: see os.system.

But don't see os.system. Use python like python.

James



More information about the Python-list mailing list