I believe most programming languages evaluate 0 to mean False, and
anything else to be True (for the purposes of boolean evaluation).
Python is no exception.


________________________________

        From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On
Behalf Of jelle feringa
        Sent: Wednesday, October 31, 2007 8:56 AM
        To: Luis Zarrabeitia
        Cc: python-list@python.org
        Subject: Re: shouldn't 'string'.find('ugh') return 0, not -1 ?
        
        
        There is a subtle point though.
        If the substring is not found '_'.find(' '), will return -1
        Semanticly, I was expecting the that if the substring was not
found, the conditional statement would not be found.
        However, python evaluates -1 to True, so that is what I do find
confusing.
        So, I was arguing that '_'.find(' ') might return 0, however
that is obviously ambigious, since 0 might be an index as well.
         
        So, perhaps I should rephrase and ask, why if -1 evaluates to
True?
        I think that's pretty ugly...
         
        cheers,
         
        -jelle

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to