[ python-Feature Requests-1483384 ] Add set.member() method

SourceForge.net noreply at sourceforge.net
Mon May 8 07:37:52 CEST 2006


Feature Requests item #1483384, was opened at 2006-05-07 10:41
Message generated for change (Comment added) made by rhettinger
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=1483384&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Extension Modules
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Michael Tsai (michaeltsai)
Assigned to: Raymond Hettinger (rhettinger)
Summary: Add set.member() method

Initial Comment:
Right now, when I check membership in a set, the __in__ method just 
returns True/False if there is an object in the set that's == to the 
argument. I would like to have a member() method that returns the object 
in the set or raises KeyError if the argument is not in the set. This would 
be useful for interning and other cases where right now I'd use a 
degenerate dictionary where the keys and values are equal.

----------------------------------------------------------------------

>Comment By: Raymond Hettinger (rhettinger)
Date: 2006-05-08 00:37

Message:
Logged In: YES 
user_id=80475

I'm curious to see some of your dictionary examples that 
do not seem to tranlate cleanly with the existing set API.

In published code, I've not seen people writing anything 
like what is being requested, i.e. I haven't seen 
fragments like:
   if x in s:
      return x
   else:
      raise KeyError



----------------------------------------------------------------------

Comment By: Georg Brandl (gbrandl)
Date: 2006-05-07 15:36

Message:
Logged In: YES 
user_id=849994

Moving to Feature Requests. Note that I do not think Raymond
will agree to this.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=1483384&group_id=5470


More information about the Python-bugs-list mailing list