Sending arguments from batch file to Python script

I am running Python 3.2 on Win XP. I am running a python script through a batch file through this:

C:\Python32\python.exe test.py %1

%1 is an argument that I pass to do some processing in a python script.

I have 2 variables in a batch file that I also want to send as arguments to a python script.

set $1=hey_hi_hello

set $2=hey_hi

I want, if possible, to do something like this:

C:\Python32\python.exe test.py %1 $1 $2

And then extract these arguments in a python script through sys.argv[2]andsys.argv[3]

Thank any help on this. Thank.

+5
source share
1 answer

your_script.bat:

set VAR_1=this
set VAR_2=that

python your_script.py %1 %VAR_1% %VAR_2%
+6
source

All Articles