Python CLI Tips and Tricks Michał Moroz
Here's a bunch of things you need for your next CLI script. Or you didn't know you needed them. Or perhaps you don't need them now, but will come in handy in the future.
- Docopt, ConfigParser and setup.py
- Docopt – a better alternative to
argparse
. - ConfigParser – settings, API tokens, etc.
- Docopt – a better alternative to
- Smart open - read/write to STDIN/STDOUT or file
- A modified
open
that usesSTDIN
/STDOUT
if-
is provided as the file name. - Useful if you need to handle both
script -o file
andscript
(the latter one printing out to console). - Handy if you use your Python tools in Bash scripting.
- A modified
More tips to follow!