[Python-bugs-list] [ python-Bugs-676072 ] rfc822.Message() doesn't support __contains__() (+patch)
SourceForge.net
noreply@sourceforge.net
Thu, 30 Jan 2003 20:35:06 -0800
Bugs item #676072, was opened at 2003-01-28 08:32
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=676072&group_id=5470
Category: Python Library
Group: Python 2.2
Status: Open
Resolution: None
Priority: 5
Submitted By: Michal Vitecek (fufsource)
Assigned to: Barry A. Warsaw (bwarsaw)
Summary: rfc822.Message() doesn't support __contains__() (+patch)
Initial Comment:
class rfc822.Message() should behave like a dictionary
but it doesn't define method __contains__() so it's not
possible to use form:
'header' in messageInstance
attached is a simple patch that fixes this.
----------------------------------------------------------------------
>Comment By: Raymond Hettinger (rhettinger)
Date: 2003-01-30 23:35
Message:
Logged In: YES
user_id=80475
Looking at the Py2.3 source, it looks like someone already
implemented many of those dictionary semantics
(including "header in msginst").
My thought was to complete this idea expressed in the
comment, "Access as a dictionary", which was followed by
definitions for len, __getitem__, __setitem__, __delitem__,
setdefault, has_key, __contains__, keys, values, and
items. So, it looked like it intended but did not succeed in
implementing the entire dictionary interface. My patch
was a simple way to fill in the blanks.
OTOH, I have zero attachment to it and won't be
disappointed if it is marked as Wont Fix and closed.
It never pays to spend much brainpower on a deprecated
module.
----------------------------------------------------------------------
Comment By: Barry A. Warsaw (bwarsaw)
Date: 2003-01-30 22:41
Message:
Logged In: YES
user_id=12800
It's not entirely clear to me that Messages should have
dictionary semantics, or that you should be able to say
"header in msginst". I don't think I'd want those semantics
for email.Message.
Messages are more than just a collection of their headers.
Why wouldn't __contains__ test for a subpart in a message
tree, or for some text in the body of the message? Also, in
email.Message, __getitem__ etc don't have dict semantics on
purpose.
----------------------------------------------------------------------
Comment By: Raymond Hettinger (rhettinger)
Date: 2003-01-30 18:40
Message:
Logged In: YES
user_id=80475
I've attached my own version of this patch for Py2.3.
The same solution was used for shelve so that a
single minimal intervention keeps the module
fully synced with mapping interface. I know this
module is superceded but it doesn't hurt to sync-up
its interface for those who still use it.
Barry, if it meets your approval please reassign
back to me.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=676072&group_id=5470