[Python-Dev] PEP 426 comment: field order (original) (raw)

Daniel Holth dholth at gmail.com
Fri Oct 19 16:29:53 CEST 2012


On Fri, Oct 19, 2012 at 10:20 AM, Barry Warsaw <barry at python.org> wrote:

On Oct 18, 2012, at 09:23 PM, Daniel Holth wrote:

The email module provides an ordered multidict interface to the data. The first tag wins (if you improperly define Name: twice for example), but the order of everything is preserved. We just don't need it, except that it might be surprising to see your classifiers randomly re-ordered. Just to be clear, the email package preserves both the order and presence of headers. So if you do add Name: twice, both will be retained. Plenty of email headers (e.g. Received) can appear multiple times. The getitem API will indeed return just the first entry, but there is an alternative API that you can use to get all of them, in order. Deletions and re-insertions obviously change the order (the insertion is always an append), although there is a .replaceheader() method for preserving existing order (kind of - only for the first instance of a header).

It's a nice interface. I was surprised that there is no collections.OrderedMultiDict.



More information about the Python-Dev mailing list