Command-Line Options

% python [-diOSuvsxXt?]
 [-c command|filename| - ][arg*]

Turn on parser debugging output (for wizards).


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


Optimize generated byte-code.


Don’t imply “import site” on initialization.


Force stdout and stderr to be totally unbuffered.


Print a message each time a module is initialized, showing the place from which it is loaded.


Suppress printing of top-level expression results.


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


Disable class-based built-in exceptions (for backward compatibility: forces string exceptions).


Warn about mixed tabs and spaces in indentation.


Print help message.

-c command

Specify a Python command (as a string) to execute.


The name of a Python script file to execute.


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


Anything else on the command line is passed to the script or command (and appears in list sys.argv[1:]).


If no script or command, Python enters interactive mode (uses GNU readline for input if installed). Command-line options can be strung together or listed individually (e.g., “python -svd” is the same as “python -s -v -d”).

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

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