Command-Line Options
Command lines are used to launch Python programs from a system shell prompt. Command-line options intended for Python itself appear before the specification of the program code to be run. Options intended for the code to be run appear after the program specification. Command lines have the following format:
python [option*] [scriptfilename| -ccommand| -mmodule| - ] [arg*]
Python Options
-bIssues warnings for calling
str()with abytesorbytearrayobject, and comparing abytesorbytearraywith astr. Option-bbissues errors instead.-BDo not write .pyc or .pyo byte-code files on imports.
-dTurns on parser debugging output (for developers of the Python core).
-EIgnores Python environment variables described ahead (such as
PYTHONPATH).-hPrints help message and exit.
-iEnters interactive mode after executing a script. Useful for postmortem debugging.
-OOptimizes generated byte-code (create and use .pyo byte-code files). Currently yields a minor performance improvement.
-OOOperates like
-O, the previous option, but also removes docstrings from byte-code.-sDo not add the user site directory to the
sys.pathmodule search path.-SDo not imply “import site” on initialization.
-uForces stdout and stderr to be unbuffered and binary.
-vPrints a message each time a module is initialized, showing the place from which it is loaded; repeats this flag for more verbose output.
-VPrints Python version number and exit.
-WargFunctions as warning control;
argtakes the formaction:
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