Command-Line Options
% python [-diOSuvsxXt?] [-ccommand|filename| - ][arg*]
-dTurn on parser debugging output (for wizards).
-iEnter interactive mode after executing a script or command, without reading $PYTHONSTARTUP. Useful for postmortem debugging.
-OOptimize generated byte-code.
-SDon’t imply “import site” on initialization.
-uForce stdout and stderr to be totally unbuffered.
-vPrint a message each time a module is initialized, showing the place from which it is loaded.
-sSuppress printing of top-level expression results.
-xSkip first line of source, allowing use of non-UNIX forms of #!cmd.
-XDisable class-based built-in exceptions (for backward compatibility: forces string exceptions).
-tWarn about mixed tabs and spaces in indentation.
-?Print help message.
-ccommandSpecify a Python command (as a string) to execute.
filenameThe name of a Python script file to execute.
-Read Python commands from stdin (the default); enter interactive mode if stdin is a tty.
arg*Anything else on the command line is passed to the script or command (and appears in list sys.argv[1:]).
Note
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”).
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access