Spot the bug: getoptquestion.py

Chris Angelico rosuav at gmail.com
Thu Jul 7 08:12:37 EDT 2016


On Thu, Jul 7, 2016 at 9:30 PM, Oscar <jornws0718 at xs4all.nl> wrote:
> 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".

Yeah, I guess, pretty much!

> 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. ;-)

>>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!

Yes, it's a third-party dependency. (Sorry, should have mentioned
that.) You're welcome to consider that to be too much risk and/or
hassle to be worth improving on getopt, but personally, I *really*
like the simplicity of just writing docstrings that still read
perfectly well as docstrings, and having them create my argparse
configs for me. Different strokes for different horses, or something
like that.

ChrisA



More information about the Python-list mailing list