Robert Kern wrote: > 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. >
Why are you retarded? Isn't the above code O(n)? Forgive me for not understanding, I'm still awfully new to Python (having come from Perl & C++), and I didn't see an explanation in the FAQ. -- http://mail.python.org/mailman/listinfo/python-list