Python style guidelines

Peter Hansen peter at engcorp.com
Thu Mar 11 10:41:09 EST 2004


Josef Meile wrote:
>>>>>> a='test'
>>>>>> if a.find('foo'):
>>>
>>>
>>> ...    print "foo was found"
>>> ...
>>> foo was found
>>
>>
>>
>> a.find does not return a boolean, so that particular style guideline
>> does not apply.
> 
> I know, but I found this on the Zope source, which
> means that there is people thinking that the False
> on python includes negative values.

I believe it's more likely they just forgot what find() did return, as 
they were writing the code.  I've done the same, thinking it was a 
boolean, not thinking that it returned a negative but that negatives 
were considered false.

-Peter



More information about the Python-list mailing list