Skip to content

Python Cli Parsing Libraries

Heath Brown edited this page Apr 30, 2024 · 1 revision

Article in the references area looks at multiple parsing libraries with sample code.

  • Argparse
  • DocOpt
  • Click
  • Invoke* as a bonus

Summary:

  • Argparse: built-in handles several cases and is popular.
  • DocOpt: Documentation focused, opionionated on how to build the tools.
  • Click: Decorator focused but clean
  • Invoke: it can do the job.

I prefer docopt as I think I like writing the documentation based approach, although I also tend to try different ones. ArgParse and DocOpt I always find I deal with handling options with if statements. The article showcases using the built-in 'func' option in Argparse to directly call a function that can handle the options.

Reference

Clone this wiki locally