rfc822.Message mapping interface
Barry A. Warsaw
barry at digicool.com
Tue May 22 10:06:49 EDT 2001
>>>>> "PM" == Postal Meowbot <meowbot at meowing.net> writes:
PM> According to The Friendly Manual, Message objects from the
PM> rfc822 module offer a read-only mapping interface to the
PM> headers. In real life, __delitem__ and __setitem__ methods
PM> exist and even do something useful (very useful for the
PM> application at hand).
PM> In this case, does it mean these methods are internal and may
PM> disappear some day, or just that the docs want updating?
I think it's just that the docs need updating. I suggest the
paragraph in
http://www.python.org/doc/current/lib/message-objects.html
be changed slightly like so:
Message instances also support a limited mapping interface. In
particular: m[name] is like m.getheader(name) but raises KeyError
if there is no matching header; and len(m), m.has_key(name),
m.keys(), m.values() and m.items() act as expected (and
consistently). Message instances also support the mapping
writeable interface m[name]=value and del m[name].
It might also make sense to mention that some mapping methods aren't
supported, e.g. update(), get(), popitem(), clear(), copy(),
setdefault().
PM> The fate of civiliation is safe in either case. I'm only
PM> trying to learn if it makes sense to maintain private copies
PM> of rfc822 and mimetools for futureproofing purposes.
If you're doing MIME, please check out http://sf.net/projects/mimelib
for a candidate of a next generation replacement for mimetools,
rfc822, MIMEWriter, etc. I've got a small backlog of updates to the
code there that I'll try to check in shortly.
-Barry
More information about the Python-list
mailing list