python commands

15 commands, each with a one-line explanation. Click a command to copy it, or its title for details.

Commands 15 shown

  • python3 -m venv .venv && source .venv/bin/activate

    Create and activate an isolated Python environment

  • pip install -r requirements.txt --no-cache-dir

    Install dependencies without using pip cache

  • pip freeze > requirements.txt

    Save exact versions of all installed packages

  • pip list --outdated --format=columns

    List packages with newer versions available

  • python3 -m http.server 8080

    Serve current directory over HTTP on port 8080

  • python3 -m json.tool < input.json

    Pretty-print a JSON file using stdlib

  • python3 -m cProfile -s cumulative script.py | head -30

    CPU profiling sorted by cumulative time

    performance · debug

  • python3 -m pdb script.py

    Start script under the Python debugger

    debug

  • breakpoint() # Python 3.7+ — drops into pdb at this line

    Built-in breakpoint() is equivalent to import pdb; pdb.set_trace()

    debug

  • pytest -x -v --tb=short tests/

    Stop at first failure, verbose, short traceback

    debug

  • python3 -m py_compile script.py && echo OK

    Compile to bytecode only to catch syntax errors

    debug

  • black --check --diff . && black .

    Preview changes then apply Black formatting

  • ruff check . --fix

    Fast linter + auto-fix (replaces flake8, isort, pyupgrade)

  • mypy --strict --ignore-missing-imports src/

    Strict static type checking for a package

    debug

  • python3 -c "import json; print([x for x in dir(json) if not x.startswith('_')])"

    List public attributes of any Python object

    debug