Calling python script in dos and passing arguments
Michael Torrie
torriem at gmail.com
Tue Apr 16 15:25:22 EDT 2013
On 04/16/2013 08:14 AM, PEnergy wrote:
> Greetings,
>
> I am trying to write a python script that, when called from the DOS
> prompt, will call another python script and pass it input variables.
> My current code will open the other python script but doesn't seem to
> pass it any values:
>
> import os,sys,subprocess
> subprocess.Popen(['python.exe','C:\NDEX\GRE2\uip\uip_20.py','t3c*'])
I find it easier just to write my python programs such that they can be
imported into other python scripts. Usually I use this form:
def func(*whatever):
pass
if __name__ == "__main__":
# parse command-line arguments
# call functions in this module with those args
func(1,2,3,etc)
This way a script can be run standalone, or I can import it and access
its attributes direction. I recommend you consider this approach.
More information about the Python-list
mailing list