Call a python script in a python script -


i trying call python script in python script. directories different. tried

import subprocess subprocess.call("c:\temp\hello2.py", shell=true) 

but got nothing. not work. reviewed many forums, of them calling when both scripts on same directory.

i tried having both scripts in same directory. in case, can run model in python.exe (through cmd window) not in idle. in idle, not error message.

i need that, such can't define other script different module, etc. need call script in script.

escape backslash (\)

"c:\\temp\\hello2.py" 

or use raw string

r"c:\temp\hello2.py" 

>>> print "c:\temp\hello2.py" c:      emp\hello2.py >>> print "c:\\temp\\hello2.py" c:\temp\hello2.py >>> print r"c:\temp\hello2.py" c:\temp\hello2.py 

Comments

Popular posts from this blog

matlab - Deleting rows with specific rules -

jquery - How would i go about shortening this code? And to cancel the previous click on click of new section? -