classification
Title: argparse: use OrderedDict to store subparsers
Type: behavior Stage:
Components: Library (Lib) Versions: Python 3.3, Python 2.7
process
Status: closed Resolution: duplicate
Dependencies: Superseder: argparse subcommands not printed in the same order they were added
View: 9026
Assigned To: Nosy List: benjamin.peterson, bethard, denversc, eric.smith
Priority: normal Keywords: patch

Created on 2010-08-06 19:31 by denversc, last changed 2010-08-10 09:49 by bethard. This issue is now closed.

Files
File name Uploaded Description Edit
argparse.patch denversc, 2010-08-06 19:31 Proposed Patch
Messages (2)
msg113124 - (view) Author: Denver Coneybeare (denversc) * Date: 2010-08-06 19:31
Currently, when a subparser is added to an argparse.ArgumentParser the list of subparsers are stored in the built-in dict type.  When these subparsers are listed when -h is given on the command line they are showed in the order returned from the dictionary's keys() method, which is undefined order.  Instead of showing them in undefined order, it would be preferred to show them at least in the order in which they were added.  This can be done trivially be replacing the dict with a collections.OrderedDict.  A patch is attached.
msg113518 - (view) Author: Steven Bethard (bethard) * (Python committer) Date: 2010-08-10 09:49
Duplicate of issue 9026.
History
Date User Action Args
2010-08-10 09:49:32bethardsetstatus: open -> closed
resolution: duplicate
superseder: argparse subcommands not printed in the same order they were added
messages: + msg113518
2010-08-06 22:06:25r.david.murraysetnosy: + bethard
2010-08-06 20:17:42eric.smithsetnosy: + eric.smith
2010-08-06 19:31:32denversccreate