What should Python apps do when asked to show help?

Dan Strohl D.Strohl at F5.com
Thu Apr 28 13:25:54 EDT 2016


Yeah, if I am handling arguments from the command line, I use argparse, if I am doing a cli based app (so, going back and forth in interacting with the command line), I would look at clint (https://github.com/kennethreitz/clint)

As many people have said here, don’t reinvent the wheel.

Dan


From: John Wong [mailto:gokoproject at gmail.com]
Sent: Thursday, April 28, 2016 10:06 AM
To: Dan Strohl <D.Strohl at F5.com>
Cc: alister <alister.ware at ntlworld.com>; python-list at python.org
Subject: Re: What should Python apps do when asked to show help?



On Thu, Apr 28, 2016 at 1:02 PM, Dan Strohl via Python-list <python-list at python.org<mailto:python-list at python.org>> wrote:
I would suggest using argparse https://docs.python.org/3/library/argparse.html as it handles all of that natively... including validating arguments, showing errors, help, etc... however, assuming you don't want to;
Totally agree with this approach. Command line should stick with argparse. Personally I'd stick with argparse and not other open source projects which is built on argparse (or optparse, the one you don't want to use, but eh some people decided to do that anyway because of some limitations in argparse).

In fact you shouldn't need to implement -h/--help when you use argparse. If a user is going to use the command line, you can almost always assume the user can use -h/--help, or for those familiar with Linux just provide a man page.

After all, what you need is a very clear documentation upfront prior to the installation so your users can refer to that for ultimate help.



More information about the Python-list mailing list