home ¦ Archives ¦ Atom ¦ RSS

Python Command Line

Python logo Intermittently over the past few years, I’ve been writing various command line apps in Python. Things like split, but with a little more complexity and in a higher level language.

I’ve often felt I wasn’t quite writing these in a Pythonic fashion. I’d stashed away Guido van Rossum’s BDFL blessed idiom for main, but never really put it to use.

Steve Lott has a much better and simpler style of writing Python main functions, that seems more easy to ingest and adopt. He even includes a nice example of how to tie option parsing into logging.

Now it would be great if someone could come up with a cookbook for using the argparse module.

© 2008-2024 C. Ross Jam. Built using Pelican. Theme based upon Giulio Fidente’s original svbhack, and slightly modified by crossjam.