Spot the bug: getoptquestion.py

Chris Angelico rosuav at gmail.com
Mon Jul 4 09:42:25 EDT 2016


On Mon, Jul 4, 2016 at 10:38 PM, Oscar <jornws0718 at xs4all.nl> wrote:
> But is this not at least a bit unexpected behaviour from getopt? On one
> hand, if I want to have trailing spaces in my longoptions, why not just
> play along and allow them? On the other hand, a space is a delimiter on
> the commandline. Does it make sense to allow it as a parameter to
> getopt()? And if getopt would silently strip it, would that be a bug?
>

This is really the crux of the matter. Honestly, I've no idea. 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).

ChrisA



More information about the Python-list mailing list