Option
python -h, list help information
python -B, don't write .pyc and .pyo file
.py: This is normally the input source code that you've written
.pyc: This is the compiled bytecode. If you import a module, python will build a *.pyc file that contains the bytecode to make importing it again later easier (and faster)
.pyo: This is a *.pyc file that was created while optimizations (-O) was on
python -c, program passed in as string
python -c "import sys; print(sys.path)"
python -E, ignore PYTHON* environment
python -o filename.py, inspect interactively after running script
python -m mod, run library module as a script
python -m site, print out the sys.path
python -m site --user-site, print out user's packages folder which is the directory where "pip install --user packagename" installs packages
python -m packageName, __main__.py will be implemented as a library module
#!/usr/bin/python
if __name__ == '__main__':
print("Run the module ...")
python -O, optimize genereated bytecode, assert will be turned off
python -OO, remove doc-strings in addition to the -O optimization
python -Q, division control
# python -Q old filename.py
print(10/4) # 2
print(10//4) # 2
# python -Q new filename.py
print(10/4) # 2.5
print(10//4) # 2
# python -Q warn filename.py, old division semantics with a warning for int/int and long/long
# python -Q warnall filename.py, old division semantics with a warning for all uses of the division operator
python -R, use a pseudo-random salt to make hash() value be unpredictable
python -s, don't add user site directory to sys.path, user site can be checked by "python -m site --user-site"
python -S, disable the import of the module site and the site-dependent manipulations of sys.path that it entails
python -t, issue warning about inconsistent tab usage
python -u, force stdin, stdout and stderr to be totally unbuffered
python -v, print a message each time a module is initialized
python -W arg, warning control
ignore, ignore all warning
default, printing each warning once per source line
all, print a warning each time it occurs
module, print each warning only the first time it occurs in each module
once, print each warning only the first time it occurs in the program
error, raise an exception instead of printing a warning message
Reference