RE Module Question.

Grant Edwards grante at visi.com
Tue Nov 6 10:25:11 EST 2001


In article <mailman.1005039367.28367.python-list at python.org>, Corrado Gioannini wrote:
> On Tue, Nov 06, 2001 at 05:49:38AM +0000, Paul Winkler wrote:
> [snip] 
>> You can do it like so:
>> 
>> test = "this is spam"
>> if test.find("spam"): print "found it"
>  
> this would fail if the sub-string to be found is at the beginning of the
> string (find returning 0).

It also fails if the string is not present, since find()
returns a -1 in that case.  

-1 is true.

-- 
Grant Edwards                   grante             Yow!  Can you MAIL a BEAN
                                  at               CAKE?
                               visi.com            



More information about the Python-list mailing list