On Thu, 06 Sep 2007 16:48:31 -0700, Zentrader wrote: > On Sep 6, 12:47 am, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: >> On Wed, 05 Sep 2007 22:54:55 -0700, TheFlyingDutchman wrote: >> > To do a "*string" wildcard filter use the endswith() function instead >> > of startswith() and to do a *string* type wildcard filter use >> > the find() function > -1. >> >> Maybe better the ``in`` operator for the '*string*' type. `str.find()` >> will go away in the future. > > string.find serves a useful purpose in that it returns the starting > location of the string found, or -1 if not found, so if you wanted to > slice "abdecf" on"c", string.find will tell you where that is.
But that position is not needed here and I think:: result = [name for name in names if 'spam' in name] reads more natural than:: result = [name for name in names if name.find('spam') > -1] Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list