Python Forum

Full Version: batch file for running python scipt in Windows shell
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

I am doing an assignement in a Python learning book in which i have to run my Python script in the Windos shell. It says that i have to make a batch file containing:

Quote:@py.exe C:\yourpath\PythonScript.py %*
@pause

What is the function of this bat file?
The @ in a batch file is suppressing the echoing of the command.
Often in batch files the following pattern is used, to switch the echoing of commands globally off:
@echo off
py.exe is the program, which finds the latest Python Interpreter on well-known paths.
C:\yourpath\PythonScript.py is the program itself.
The %* is for arguments.
google Wrote:%* expands to the complete list of arguments passed to the script. You typically use it when you want to call some other program or script and pass the same arguments that were passed to your script. The %* modifier is a unique modifier that represents all arguments passed in a batch file.

The command pause will be executed after the python program has been finished. The command pause waits for a key press.
This is often used to see debug output from a broken program. If it was not run direct in a terminal, the new terminal will instantly close, and you've no time to read the Exceptions.
Thank you for the info. But what is the purpose of this batch file, as i can already run the .py program from the system shell?