- publishing free software manuals
An Introduction to Python
by Guido van Rossum and Fred L. Drake, Jr.
Paperback (6"x9"), 124 pages
ISBN 0954161769
RRP £12.95 ($19.95)

Sales of this book support the Python Software Foundation! Get a printed copy>>>

2.2.2 Executable Python Scripts

On BSD'ish UNIX systems, Python scripts can be made directly executable, like shell scripts, by putting the line

    #! /usr/bin/env python

(assuming that the interpreter is on the user's ‘PATH’) at the beginning of the script and giving the file an executable mode. The ‘#!’ must be the first two characters of the file. On some platforms, this first line must end with a UNIX-style line ending (‘\n’), not a Mac OS (‘\r’) or Windows (‘\r\n’) line ending. Note that the hash, or pound, character, ‘#’, is used to start a comment in Python.

The script can be given an executable mode, or permission, using the chmod command:

    $ chmod +x myscript.py
ISBN 0954161769An Introduction to PythonSee the print edition