Linux Today: Linux News On Internet Time.
Search Linux Today
Linux News Sections:  Developer -  High Performance -  Infrastructure -  IT Management -  Security -  Storage -
Linux Today Navigation
LT Home
Contribute
Contribute
Link to Us
Linux Jobs


Top White Papers

More on LinuxToday


Python's optparse for human beings

Apr 30, 2009, 00:03 (0 Talkback[s])

[ Thanks to Alexander Sandler for this link. ]

"Every time we use optparse, we use it to do a number of things. Obviously we want our program to support command line options. What varies is the type of options we want to support. Some options doesn’t have additional arguments (boolean options). Others are mandatory. Some require one or more arguments. Finally, we may want options to depend on each other - i.e. we may want one option to depend on presence of another.

"These are most common things that we would like to implement, but there are more. Lets try to build a list of all such functionalities that we may want to implement.

"Support for a standalone command line options (boolean options).
Support for mandatory (required) options.
Support for options with one or more arguments.
Default values for options.
Dependency between options.
Grouping of options in help screen.
Customizing help screen.

"However, before we dig into implementation details of each and every one of these bullets, lets see the basics of using optparse."

Complete Story

Related Stories: