[nycbug-talk] Python Command-Line Option Parser

Isaac Levy ike
Tue Jun 21 14:59:00 EDT 2005


Hey All,

Saw something in today's Daily Python-URL which I thought relevant to 
an ongoing discussion about using Python for general UNIX tasks, 
someone posted a nice "Generic command-line option parser" class.

Cool stuff, primarily, because it's aimed at solving the problems (and 
some libraries brokenness) of various command-line calling schemes in 
core Python.  Not certain that this code totally solves the problem, 
but from skimming it, it looks to be a great stab at trying to...


Generic command-line option parser
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/425345

"""
I have seen Python programmers having to write custom code when faced 
with the task of doing command line argument parsing. Some use optparse 
which limits your application to Python 2.3 +, some stick to getopt 
which makes sure that the program works with all versions of Python, 
but loses the power of optparse. Some uses neither and develops custom 
code.

This class resolves the dilemma, by providing a single mechanism which 
wraps up both optparse and getopt...
"""

Source code posted online, I'll be trying it myself this weekend...  
See yall' on IRC!

Rocket,
.ike





More information about the talk mailing list