Command-Line Options

python [option*]
  [ scriptfilename | -c command | - ] [arg*]

Python Options

-d

Turn on parser debugging output (for developers of the Python core).

-i

Enter interactive mode after executing a script or command, without reading the PYTHONSTARTUP file. Useful for postmortem debugging.

-O

Optimize generated byte-code (create and use .pyo byte-code files). Currently yields a minor performance improvement.

-OO

Like -O, but also removes docstrings from byte-code.

-S

Don’t imply “import site” on initialization.

-t

Issue warnings about inconsistent tab usage (-tt issues error instead).

-u

Force stdout and stderr to be unbuffered and binary.

-U

Unicode literals: 'xxx' treated like u'xxx' (highly experimental in 2.1.1).

-v

Print a message each time a module is initialized, showing the place from which it is loaded; repeat this flag for more verbose output.

-x

Skip first line of source, allowing use of non-Unix forms of #!cmd.

-h

Print help message and exit.

-V

Print Python version number and exit.

-W arg

Warning control; arg is action:message:category:module:lineno. See warnings module documentation, new in 2.1, in the Python Library Reference (http://www.python.org/doc/).

Program Specification

scriptfilename

The name of a Python scriptfile to execute; the main, topmost file of a program, made available in sys.argv[0].

-c command

Specifies a Python command (as a string) to execute; sys.argv[0] is set to -c.

-

Read Python commands from stdin (the default); enter interactive mode if stdin is a ...

Get Python Pocket Reference, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.