[Python-Dev] PEP 389: argparse - new command line parsing module
ubershmekel at gmail.com
Mon Sep 28 17:18:45 CEST 2009
> * Would you be opposed to a note in the getopt documentation suggesting
> argparse as an alternative?
from the top of http://docs.python.org/library/getopt.html - "A more
convenient, flexible, and powerful alternative is the optparse module."I
think this statement should be emphasized better but it's already there so
* Would you like argparse to grow an add_getopt_arguments method (as in my
> other post)?
* If argparse grew an add_getopt_arguments, would you still want to keep
> getopt around? And if so, why?
Argparse/optparse use a parser instance and getopt doesn't. I think that's a
saved line you have to keep saving so this would be the better syntax imho:
optlist, args = argparse.getopt(args, 'abc:d:')
I was thinking on the general issue of what's better for the std-lib:
1. Mini modules - 3+ small modules in each subject that can be useful in
different contexts. For example the xml libs.
2. Big modules - 1 uber-module for each subject that does everything. Maybe
logging is an example of this.
I think in general python std-lib went the path of mini modules. Its
1. Each mini module can be coherent and while python isn't really
OnlyOneWayToDoIt, each module in itself has OnlyOneWayToDoIt.
2. Documentation is less cluttered by a large amount of functions that all
do the same thing but differently. This is very important for python's
1. You have to craft your documentation carefully as to be very explicit on
why you have all these modules for the same thing. Probably each module
should explain it's purpose in relation to the other modules and this
explanation should appear at the top of the documentation of each of the
mini modules in the subject. Today it would be very hard for me to figure
out how the xml modules interrelate, urllib has improved in python3 but
still isn't perfect.
2. I could be using some silly way of doing things (getopt) while I really
wanted to do it the good way (argparse).
I think that while adding getopt functionality to argparse might be nice but
would eventually cause clutter.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-Dev