Skip to content

Instantly share code, notes, and snippets.

@tchiavegatti
Forked from jadient/python-batchfile.bat
Created May 6, 2019 14:08
Show Gist options
  • Save tchiavegatti/3aa8efdc008eebe07afa24ef7a1e0f3a to your computer and use it in GitHub Desktop.
Save tchiavegatti/3aa8efdc008eebe07afa24ef7a1e0f3a to your computer and use it in GitHub Desktop.
Run python code directly from a batch file
@echo off & python -x "%~f0" %* & goto :eof
# ==========================================================
# one way to place python script in a batch file
# place python code below (no need for .py file)
# ==========================================================
import sys
print "Hello World!"
for i,a in enumerate(sys.argv):
print "argv[%d]=%s" % (i,a)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment