Proposed new collection methods
Robert Kern
rkern at ucsd.edu
Sat Aug 6 22:14:58 EDT 2005
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.
--
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