[issue9182] document “--” as a way to disti nguish option w/ narg='+' from positional argument in arg parse

2010-11-21 Thread Daniel Albeseder

Daniel Albeseder ko...@gmx.at added the comment:

Steven: From msg121850 I think the last two examples do not need the --. 
Since there are no positional arguments, the -- is not needed. However the 
following additional cases exist:

-x X [X ...] -y Y -- A B # since optionals might come in other order

Basically every of the three variable length classes need to be tested: 
ZeroOrOne, ZeroOrMore and OneOrMore. This might always come in a conflict with 
positional arguments needed afterward (even with optional positional 
arguments!).

BTW - I recognized the following seem to be supported:

for [-x [X ...]] -- [y ...] 
the following input: a -x -- b

I would expect to be 'a' and 'b' positional arguments and the optional '-x' has 
no argument. However this seem not to work. Another issue or desired behavior?

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9182
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9182] document “--” as a way to disti nguish option w/ narg='+' from positional argument in arg parse

2010-11-21 Thread Daniel Albeseder

Daniel Albeseder ko...@gmx.at added the comment:

Added more unit tests for testing the help text as well as the functionality of 
the -- separator.

--
keywords: +patch
Added file: http://bugs.python.org/file19731/issue9182.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9182
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9182] document “--” as a way to disti nguish option w/ narg='+' from positional argument in arg parse

2010-11-21 Thread Daniel Albeseder

Changes by Daniel Albeseder ko...@gmx.at:


Removed file: http://bugs.python.org/file19731/issue9182.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9182
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9182] document “--” as a way to disti nguish option w/ narg='+' from positional argument in arg parse

2010-11-21 Thread Daniel Albeseder

Changes by Daniel Albeseder ko...@gmx.at:


Added file: http://bugs.python.org/file19732/issue9182.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9182
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9182] document “--” as a way to disti nguish option w/ narg='+' from positional argument in arg parse

2010-11-21 Thread Steven Bethard

Steven Bethard steven.beth...@gmail.com added the comment:

Yeah, sorry, those last two should have had arguments after them.

I think we have to stick with the current behavior - otherwise there's no way 
to do something like -x -A -B, where you want -A and -B to be arguments to -x. 
(You can get that now with -x -- -A -B.)

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9182
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9182] document “--” as a way to disti nguish option w/ narg='+' from positional argument in arg parse

2010-11-21 Thread Daniel Albeseder

Daniel Albeseder ko...@gmx.at added the comment:

Steven: The last part I guess would belong better in issue 9334. Using a -- 
to end all optionals is just a convention but -- could also be the argument 
to some option as well. We need to limit this in any way, and the way it is 
done right now seem very reasonable for me.

Adding some additional unit tests testing this limits might be beneficial but I 
guess would be best done during issue 9334.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9182
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9182] document “--” as a way to disti nguish option w/ narg='+' from positional argument in arg parse

2010-11-20 Thread Daniel Albeseder

Daniel Albeseder ko...@gmx.at added the comment:

I did the patch for adding the -- in the generated usage text inside issue 
9338.

--
nosy: +Kotan

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9182
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9182] document “--” as a way to disti nguish option w/ narg='+' from positional argument in arg parse

2010-11-20 Thread Steven Bethard

Steven Bethard steven.beth...@gmail.com added the comment:

Sorry, I think I confused you, please post that patch here. This issue is for 
documenting the workarounds, issue 9338 is for actually solving the problem.

I glanced at your patch on that issue, and it looks basically okay, though I'd 
like to see a few more tests for the help messages to cover things like:

   -x X A   # no --
   -x [X [X ...]] -y Y [Y ...]  # no --
   -x [X] -- A B# needs --
   -x X [X ...] # needs --
   -x [X [X ...]]   # needs --

It's possible the first two are already covered by the other tests, but at 
least the last three should all be tested for.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9182
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9182] document “--” as a way to disti nguish option w/ narg='+' from positional argument in arg parse

2010-11-19 Thread Éric Araujo

Éric Araujo mer...@netwok.org added the comment:

Sergey: Do you want to make a patch for that, and/or for the documentation?  
Guidelines are on http://www.python.org/dev/patches/

--
nosy: +bethard
resolution: accepted - 
versions: +Python 3.1, Python 3.2 -Python 2.6

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9182
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9182] document “--” as a way to disti nguish option w/ narg='+' from positional argument in arg parse

2010-11-19 Thread Steven Bethard

Steven Bethard steven.beth...@gmail.com added the comment:

The original point is basically a duplicate of issue 9338. It is undesirable 
behavior, I just don't know how to fix it. Patches to fix it are welcome (on 
issue 9338). ;-)

As to documenting '--', I agree it's hidden too far down in the documentation 
currently. I'd be happy to approve any documentation patch that makes the '--' 
workaround more visible.

--
versions:  -Python 3.1

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9182
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9182] document “--” as a way to disti nguish option w/ narg='+' from positional argument in arg parse

2010-11-19 Thread Éric Araujo

Éric Araujo mer...@netwok.org added the comment:

You’re right, sorry I was unclear: “a patch for that” referred to the addition 
of “--” in the generated usage text.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9182
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9182] document “--” as a way to disti nguish option w/ narg='+' from positional argument in arg parse

2010-07-06 Thread Éric Araujo

Éric Araujo mer...@netwok.org added the comment:

I always forget that not all programs follow getopt-style parsing rules, thanks 
for the reminder.

--
keywords: +easy
resolution:  - accepted
title: argparse: optional argument w/ narg='+' conflicts w/ positional 
argsument - document “--” as a way to distinguish option w/ narg='+' from 
positional argument in argparse

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9182
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9182] document “--” as a way to disti nguish option w/ narg='+' from positional argument in arg parse

2010-07-06 Thread Sergey Konoplev

Sergey Konoplev gray...@gmail.com added the comment:

Thank you for the hint. It is realy not so obvious.

May be it is worth to add -- into the usage string this way

usage: [-h] [-b BAR [BAR ...]] -- foo

Otherwise it leads to misunderstanding.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9182
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com