Search code examples
pythoncommand-line

What does "python3 -t" do?


$ python3 -t -c 'print("hello world")'
hello world

What does -t do? It's not mentioned in python3 --help.

Usually unknown options cause a non-zero exit code, like

$ python3 -r
Unknown option: -r
usage: python3 [option] ... [-c cmd | -m mod | file | -] [arg] ...
Try `python -h' for more information.

Solution

  • The -t option in python3 was a feature from Python 2.x that warned about inconsistent use of tabs and spaces in the source code. However, this option was removed in Python 3.x.

    Therefore, when you run python3 -t -c 'print("hello world")', Python 3 just ignores the -t option and executes the code as usual.