Scripts
- A common extension for Python scripts is
.py
Shebang
- The first line must be one of the
following, to indicate
that the file is a Python script:
#!/usr/bin/python
#!/usr/bin/env python
- There's some controversy over which of
the above approaches is best.
- To find out which location python is run
from on a given computer, type
"
which python"
Executable Python scripts
- The access rights for the file must be
set so that the file is
executable.
- Under Unix, a complete program can be
passed to the interpreter
in three forms: with the
-c string command line option,
as a file
passed as the first command line argument, or as standard input.
- If the file or standard input is a tty
device, the interpreter
enters interactive mode; otherwise, it executes the file as a complete
program.