Spot the bug: getoptquestion.py

Oscar jornws0718 at xs4all.nl
Thu Jul 7 07:30:46 EDT 2016


In article <mailman.118.1467778498.2295.python-list at python.org>,
Chris Angelico  <rosuav at gmail.com> wrote:
>On Wed, Jul 6, 2016 at 2:04 PM, Lawrence D’Oliveiro
><lawrencedo99 at gmail.com> wrote:
>> On Tuesday, July 5, 2016 at 1:42:42 AM UTC+12, Chris Angelico wrote:
>>
>>> The getopt module is designed to match the C getopt function, which I've
>>> never used; for my command-line parsing, I use argparse instead
>>> (usually via some wrapper that cuts down the duplication, like clize).
>>
>> getopt seems so much simpler.
>
>Look at clize:

Okay:

| >>> import clize
| Traceback (most recent call last):
|  File "<stdin>", line 1, in <module>
| ImportError: No module named clize

Mmm... nope. I'm not going to learn a new tool and introduce an extra
dependency just to do something as basic as getopt. But then again,
coming from a C background, getopt feels kind of familiar. ;-)

Thanks all for the input. I think it all boils down to: "If you don't
want a space in your long_option, don't put a space in there".


>I just put docstrings on my functions, slap "@command" above them, and
>with minimal boilerplate, I have a fully-working command line
>interface. It's a wrapper around argparse.

Looks neat though! 
-- 
[J|O|R] <- .signature.gz



More information about the Python-list mailing list