Proposed new collection methods

Robert Kern rkern at ucsd.edu
Sun Aug 7 04:19:32 CEST 2005


Robert Kern wrote:
> Christopher Subich wrote:
> 
> 
>>Dear Zeus no.  Find can be defined as:
>>def find(self, test=lambda x:1):
>>    try:
>>       item = (s for s in iter(self) if test(s)).next()
>>    except StopIteration:
>>       raise ValueError('No matching items in list')
> 
> I would prefer that a find() operation return as soon as it locates an 
> item that passes the test. This generator version tests every item.

Pardon me, I am retarded.

-- 
Robert Kern
rkern at ucsd.edu

"In the fields of hell where the grass grows high
  Are the graves of dreams allowed to die."
   -- Richard Harter




More information about the Python-list mailing list