0

Is there a Mac equivalent to the Windows Batch code below? Really the first line is what I care about. I just purchased a Mac and have really grown used to running Python scripts from within .bat files for ease of use.

@echo off & python -x "%~f0" %* & goto :PrintInBatch

print(‘This was printed from Python’)

echo = """
:PrintInBatch
echo This was printed from Batch """

A simpler example would just be something like this:

@echo off & python -x "%~f0" %* % goto :eof

print('This was printed from Python')

With this setup, you can just double click the .bat file and it runs the Python code inside. Can this be done with MacOS?

Shane
  • 13
  • 1
  • 4
  • In your case, you don't need any shell wrapper. Just make the first line `#!/usr/bin/python` (or wherever your Python is located). – user1934428 Oct 20 '21 at 13:26

0 Answers0