Command-Line Options

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

Python Options


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


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


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


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


Don’t imply “import site” on initialization.


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


Force stdout and stderr to be unbuffered and binary.


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


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


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


Print help message and exit.


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 (

Program Specification


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.