Issue 74 in argparse: Subcommands not printed in the same order they were added

0 views
Skip to first unread message

argp...@googlecode.com

unread,
Jun 18, 2010, 5:00:53 AM6/18/10
to argpar...@googlegroups.com
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 74 by javier.collado: Subcommands not printed in the same order
they were added
http://code.google.com/p/argparse/issues/detail?id=74

What steps will reproduce the problem?
1. Run 'python subcommands.py -h' (attached file)
2. Check the ordering of the subcommands in the output:
----
subcommands:
{a,c,b,e,d}
a a subcommand help
b b subcommand help
c c subcommand help
d d subcommand help
e e subcommand help
----

The ordering between brackets is different than the ordering in the
one-line help for each command below. This could be a little confusing to
the user.


What is the expected output? What do you see instead?
The expected output would be to use the same ordering in both places. In
particular the same ordering that was used in the code when using the
_SubParsersAction.add_parser method:
----
subcommands:
{a,b,c,d,e}
a a subcommand help
b b subcommand help
c c subcommand help
d d subcommand help
e e subcommand help
----


What version of the product are you using? On what operating system?
OS: Ubuntu
Version: source code (rev. 87)
Python: 2.6.5

Please provide any additional information below.
Please have a look at the attached diff. It contains a patch that worked
for me to preserve the ordering used in the code.

To make that possible it uses action._choices_actions (a list) instead of
action.choices (a dictionary).


Attachments:
subcommands.py 855 bytes
ordered_subcommands.diff 542 bytes

argp...@googlecode.com

unread,
Jun 18, 2010, 5:11:16 AM6/18/10
to argpar...@googlegroups.com

Comment #1 on issue 74 by javier.collado: Subcommands not printed in the

This issue is probably present also in the python 2.7 sources in which the
argparse library has been added. Should I report this in the python issue
tracker as well?

argp...@googlecode.com

unread,
Jun 18, 2010, 6:14:14 AM6/18/10
to argpar...@googlegroups.com

Comment #2 on issue 74 by steven.bethard: Subcommands not printed in the

Yes, please report this to the Python issue tracker (for both Python 2.7
and 3.2). I plan to close down the Google code tracker, I just haven't had
the time yet.

argp...@googlecode.com

unread,
Jun 18, 2010, 6:28:32 AM6/18/10
to argpar...@googlegroups.com

Comment #3 on issue 74 by javier.collado: Subcommands not printed in the

Done:
http://bugs.python.org/issue9026

argp...@googlecode.com

unread,
Jul 23, 2010, 10:23:47 AM7/23/10
to argpar...@googlegroups.com
Updates:
Status: Duplicate

Comment #4 on issue 74 by steven.bethard: Subcommands not printed in the

Moved to bugs.python.org.

Reply all
Reply to author
Forward
0 new messages