feature request: a better str.endswith

Chris Perkins chrisperkins37 at hotmail.com
Mon Jul 21 09:22:49 EDT 2003


mis6 at pitt.edu (Michele Simionato) wrote in message news:<2259b0e2.0307200721.16ef2ea1 at posting.google.com>...
> Oops! My mistake, I forgot the islice; it should be
> 
> the=lambda pred,seq: list(itertools.islice(itertools.ifilter(pred,seq),0,1))
> 
> in such a way that we exit at the first hit, otherwise one could just use
> the standard "filter". 

How about:

def the(pred,seq): return True in itertools.imap(pred,seq)

if you really want to use the name "the" ("any" makes much more sense to me).

Chris




More information about the Python-list mailing list