Re: Spot the bug: getoptquestion.py

2016-07-25 Thread Steven D'Aprano
On Thu, 7 Jul 2016 09:30 pm, Oscar 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". No, I don't think so. I think we can do better than that: http://bugs.python.org/issue27619 What decided it for me

Re: Spot the bug: getoptquestion.py

2016-07-07 Thread Oscar
In article , Chris Angelico wrote: >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 r

Re: Spot the bug: getoptquestion.py

2016-07-07 Thread Chris Angelico
On Thu, Jul 7, 2016 at 9:30 PM, Oscar 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 j

Re: Spot the bug: getoptquestion.py

2016-07-07 Thread Oscar
In article , Chris Angelico wrote: >On Wed, Jul 6, 2016 at 2:04 PM, Lawrence D’Oliveiro > 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

Re: Spot the bug: getoptquestion.py

2016-07-05 Thread Chris Angelico
On Wed, Jul 6, 2016 at 2:04 PM, Lawrence D’Oliveiro 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 wr

Re: Spot the bug: getoptquestion.py

2016-07-05 Thread Lawrence D’Oliveiro
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 s

Re: Spot the bug: getoptquestion.py

2016-07-04 Thread Chris Angelico
On Mon, Jul 4, 2016 at 10:38 PM, Oscar 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 mak

Re: Spot the bug: getoptquestion.py

2016-07-04 Thread Oscar
In article , Chris Angelico wrote: >On Mon, Jul 4, 2016 at 9:24 PM, Oscar wrote: >> Is this: >> >> a) a bug in getopt.getopt >> b) a bug in my code >> c) a great way to keep me busy for a while >> d) all of the above? >> >> >> #!/usr/bin/python >> >> from __future__ import print_function >> from

Re: Spot the bug: getoptquestion.py

2016-07-04 Thread Chris Angelico
On Mon, Jul 4, 2016 at 9:24 PM, Oscar wrote: > Is this: > > a) a bug in getopt.getopt > b) a bug in my code > c) a great way to keep me busy for a while > d) all of the above? > > > #!/usr/bin/python > > from __future__ import print_function > from getopt import getopt, GetoptError > import sys >

Spot the bug: getoptquestion.py

2016-07-04 Thread Oscar
Is this: a) a bug in getopt.getopt b) a bug in my code c) a great way to keep me busy for a while d) all of the above? #!/usr/bin/python from __future__ import print_function from getopt import getopt, GetoptError import sys try: opts, args = getopt(sys.argv[1:], 'b', ['bug ']) except Ge