Why is the argparse module so inflexible?
rusi
rustompmody at gmail.com
Sat Jun 29 00:12:34 EDT 2013
On Saturday, June 29, 2013 7:06:37 AM UTC+5:30, Ethan Furman wrote:
> On 06/27/2013 03:49 PM, Steven D'Aprano wrote:
> > [rant]
> > I think it is lousy design for a framework like argparse to raise a
> > custom ArgumentError in one part of the code, only to catch it elsewhere
> > and call sys.exit. At the very least, that ought to be a config option,
> > and off by default.
> >
> > Libraries should not call sys.exit, or raise SystemExit. Whether to quit
> > or not is not the library's decision to make, that decision belongs to
> > the application layer. Yes, the application could always catch
> > SystemExit, but it shouldn't have to.
>
>
> So a library that is explicitly designed to make command-line scripts easier
> and friendlier should quit with a traceback?
>
> Really?
So a library that behaves like an app is OK?
Really?
I would have thought that with the sophistication of python's exception mechanism in place there would be corresponding peps in place proscribing such behavior. In the same way that if I submitted my super-duper library for inclusion into python with 7 spaces indentation, some kind dev would reply with
http://www.python.org/dev/peps/pep-0008/#indentation
More information about the Python-list
mailing list