Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!us.feeder.erje.net!news.snarked.org!newsfeed.news.ucla.edu!usenet.stanford.edu!panix!not-for-mail From: Grant Edwards Newsgroups: comp.lang.python Subject: Re: Eval of expr with 'or' and 'and' within Date: Fri, 14 Jun 2013 19:36:29 +0000 (UTC) Organization: PANIX Public Access Internet and UNIX, NYC Lines: 31 Message-ID: References: <51BB44E5.9010201@gmail.com> NNTP-Posting-Host: dsl.comtrol.com X-Trace: reader1.panix.com 1371238589 29090 64.122.56.22 (14 Jun 2013 19:36:29 GMT) X-Complaints-To: abuse@panix.com NNTP-Posting-Date: Fri, 14 Jun 2013 19:36:29 +0000 (UTC) User-Agent: slrn/1.0.1 (Linux) Xref: csiph.com comp.lang.python:48215 On 2013-06-14, Nick the Gr33k 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?