[issue34160] ElementTree not preserving attribute order

Raymond Hettinger report at bugs.python.org
Thu Oct 25 13:10:00 EDT 2018


Raymond Hettinger <raymond.hettinger at gmail.com> added the comment:

Consider this as a feature request.  It is perfectly reasonable for a user to want to generate specific XML output and to want to control the order that the attributes are listed.  It is perfectly reasonable for the API to preserve the order that the user specified rather than change it into some other order that they either don't expect or can't control.  Starting in Python 3.6, the language guarantees that the order of keyword arguments is preserved.  Knowing that, it will be natural for users to start viewing as buggy APIs that discard that order when everything else in the eco-system respects the ordering.

When I teach ElementTree in Python courses, students notice this behavior and ask why the order was swapped.  My only answer is that we didn't used to have a way to control it, so the input order was ignored (i.e. a reason that no longer makes sense).

----------
type: behavior -> enhancement
versions:  -Python 3.6, Python 3.7

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


More information about the Python-bugs-list mailing list