Python
Quick Webserver
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
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
# pip >= 21.2
pip index versions <packagename>