On 2013-06-14, Nick the Gr33k <supp...@superhost.gr> wrote:
> On 14/6/2013 7:47 ????, Benjamin Kaplan wrote:
>   In an "and" clause,
>> python returns the first false value or the last value, because that
>> will evaluate to the correct Boolean value. In an "or" clause, python
>> returns the first true value or the last value. When Python finally got
>> a Boolean type, no one wanted to break backwards compatibility for this.
>
>
> This is exactly what i dont understand and thats why i keep asking and 
> people call me an idiot. I just dont understand why it behaves like that.
>
> Why return first or last value?

There are cases where it's useful not only to know wether an
expression was True or False, but _why_ it was true or false.

> because that will evaluate to the correct Boolean value ????

Yes.  All values in Pyton have a "truthness" and you can be guaranteed
that 

     if A or B or C:

will behave exactly the same way whether the "or" operator returns
True or it returns one of it's operands.  

-- 
Grant Edwards               grant.b.edwards        Yow! Where do your SOCKS
                                  at               go when you lose them in
                              gmail.com            th' WASHER?
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to