Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion Doc/using/cmdline.rst
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,25 @@ Miscellaneous options
.. option:: -x

Skip the first line of the source, allowing use of non-Unix forms of
``#!cmd``. This is intended for a DOS specific hack only.
``#!cmd``.

This can be used to turn a Python script into a Windows batch file.
Similarly to adding a shebang line and setting the executable bit on Unix,
the extension of the Python script can be changed to ``.bat`` and the
following line can be added at the start of the script:

.. code-block:: batch

@py -x "%~f0" %* & exit /b

Or, to specify the path to the Python interpreter explicitly:

.. code-block:: batch

@"C:\Path\to\python.exe" -x "%~f0" %* & exit /b

Unlike a shebang line which is a Python comment, this line is not valid
Python syntax, and the :option:`-x` option is needed to skip it.


.. option:: -X
Expand Down
Loading