On Sat, 15 Jun 2013 18:55:05 -0700, Tim Roberts wrote: > Nick the Gr33k <supp...@superhost.gr> wrote: >> >>but i'm doing this all day long i just dont comprehend why it works this >>way. it doesn't make any sense to me. > > It's just a rule you'll have to learn. The "and" and "or" operators in > Python simply do not return a boolean value. The expression "a or b" is > evaluated as: > if a is true then return a otherwise return b
I prefer to say that as "if a is true-ish then return a otherwise return b" or even "if a quacks like a true value then return a otherwise return b" to emphasis that this is a form of duck-typing, and avoid any confusion with "if a is True". But otherwise, well said. -- Steven -- http://mail.python.org/mailman/listinfo/python-list