Python Forum
batch file for running python scipt in Windows shell - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: batch file for running python scipt in Windows shell (/thread-36149.html)



batch file for running python scipt in Windows shell - MaartenRo - Jan-21-2022

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?


RE: batch file for running python scipt in Windows shell - DeaD_EyE - Jan-21-2022

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.


RE: batch file for running python scipt in Windows shell - MaartenRo - Jan-21-2022

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?