[issue39058] argparse should preserve argument ordering in Namespace

Eric Snow report at bugs.python.org
Tue Dec 17 11:24:41 EST 2019


Eric Snow <ericsnowcurrently at gmail.com> added the comment:

> Currently, Namespace() objects sort the attributes in the __repr__.  This is annoying because argument
> order matters and because everywhere else in the module we preserve order (i.e. users see help in the
> order that arguments are added).

Hmm, I was going to suggest switching to types.SimpleNamespace, but
realized we sort that repr too (likely for the same reason).  I've
opened issue #39075 to address that.

In writing up that issue, I considered that a sorted repr can be
useful in some cases.  However, I don't think any of those cases
really apply here.

Anyway, I agree with your conclusion. :)

----------
nosy: +eric.snow

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue39058>
_______________________________________


More information about the Python-bugs-list mailing list