Gilles Ganault wrote: > On Wed, 08 Apr 2009 12:11:55 +0200, Ulrich Eckhardt > <eckha...@satorlaser.com> wrote: >>find() returns the index where it is found or -1 if it is not found. Both >> an >>index>0 or a -1 evaluate to True when used as conditional expression. > > Thanks everyone. I shouldn't have assumed that "if test.find(item):" > was necessarily enough to mean True. > > for item in isp: > #GOOD if item in test: > if test.find(item) > 0:
the post you quote has an error. you probably want > -1 there. 0 is returned if the two strings match at the start. the problem is that the method return isn't consistent with implicit conversion to boolean; python does convert non-zero to True. andrew > print test > -- > http://mail.python.org/mailman/listinfo/python-list > > -- http://mail.python.org/mailman/listinfo/python-list