On Fri, Oct 19, 2012 at 10:20 AM, Barry Warsaw <ba...@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 .replace_header() 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.
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to