LinuxCommandLibrary

python

TLDR

Run Python script

$ python [script.py]
copy
Start interactive REPL
$ python
copy
Execute code
$ python -c "[print('Hello')]"
copy
Run module
$ python -m [module]
copy
Start HTTP server
$ python -m http.server [8080]
copy
Check syntax
$ python -m py_compile [script.py]
copy

SYNOPSIS

python [options] [script] [args]

DESCRIPTION

python is the Python interpreter. General-purpose programming language.
The tool runs Python code. Scripting and application development.
python executes Python.

PARAMETERS

SCRIPT

Python script to run.
ARGS
Script arguments.
-c CODE
Execute code string.
-m MODULE
Run library module.
-i
Interactive after script.
-O
Optimize bytecode.
-V
Show version.
-u
Unbuffered output.

CAVEATS

Python 2 vs 3 differences. Use python3 for Python 3.

HISTORY

Python was created by Guido van Rossum in 1991.

SEE ALSO

python3(1), pip(1), pydoc(1)

Copied to clipboard