Python

Quick Webserver

Source

Create a webserver in the current working directory and server whatever is there on port 8000:

# Python 2
$ python -m SimpleHTTPServer

# Python 3
$ python3 -m http.server

# Twistd
$ twistd -n web -p 8000 --path .

Positional Parameters

Source

import argparse

parser = argparse.ArgumentParser(
    description='Something very smart'
    )
parser.add_argument('--input', '-i',
                    required=True,
                    metavar='<dir>',
                    help='Some helpful text',
                    action='store_true')
"""
Rince and repeat.
"""

args = parser.parse_args()
print(args.input)

Script header

#!/usr/bin/python3
# -*- coding: utf8 -*-
#

Module template


def main():
    pass

if __name__ == "__main__":
    main()

Clear pip cache

pip cache purge

List available package versions

Source

# pip >= 21.2
pip index versions <packagename>
  • wily, tracking and reporting on timing on complexity in projects
  • radon, Compute code metrics