Tricks and tips
TODO: Move more here.
docopt at https://github.com/docopt/docopt and described at http://docopt.org/ creates custom CLI commands by parsing a command help text into cli code that implements it.
Dan Bader recommends the use of the
http://click.pocoo.org/6/why/ click custom package (from Armin Ronacher) instead of the argparse package that comes with Python 3.2+ (and the optparse package that comes with Python 2).
Click provides decorators such as the “@click.command()” below:
\# cli.py import click @click.command() def main(): print("I'm a beautiful CLI ✨") if __name__ == "__main__": main()
squares = [x * x for x in range(10)]
[0, 1, 4, 9, 16, 25, 36, 49, 64, 81]