Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python,': 0.02; 'expressions': 0.07; "subject:' ": 0.07; 'compact': 0.09; 'expected.': 0.09; 'latter': 0.09; 'received:151': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'wrote': 0.14; '"a"': 0.16; '"and"': 0.16; '"is"': 0.16; '"or"': 0.16; 'doing,': 0.16; 'emanuele': 0.16; 'nick': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'simpson': 0.16; 'year)': 0.16; 'wrote:': 0.18; 'seems': 0.21; '>>>': 0.22; 'header:User- Agent:1': 0.23; 'header:X-Complaints-To:1': 0.27; 'evaluation': 0.30; 'gives': 0.31; 'operations.': 0.31; 'writes:': 0.31; 'subject:with': 0.35; 'something': 0.35; 'but': 0.35; 'false': 0.36; 'should': 0.36; 'clear': 0.37; 'needed': 0.38; 'to:addr :python-list': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'che': 0.60; 'back': 0.62; 'name': 0.63; 'myself': 0.63; 'more': 0.64; 'results': 0.69; 'you:': 0.81; 'quando': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Lele Gaifax Subject: Re: Eval of expr with 'or' and 'and' within Date: Sat, 15 Jun 2013 11:48:05 +0200 Organization: Nautilus Entertainments References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Gmane-NNTP-Posting-Host: 151.62.75.33 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) Cancel-Lock: sha1:A/6EKqcaWMc9wstWcf40GO24FdE= X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 38 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1371289687 news.xs4all.nl 16005 [2001:888:2000:d::a6]:51678 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:48276 Nick the Gr33k writes: > On 15/6/2013 3:14 πμ, Cameron Simpson wrote: >> But for what you are doing, "and" and "or" are not good operations. >> >> Something like: >> >> "k" in (name+month+year) >> >> or >> >> "k" in name or "k" in month or "k" in year > > Used to wrote it myself like the latter but needed a more compact way > of writing it for clarity so i used the former. > > but those 2 gives the same results back > > "k" in (name+month+year) == "k" in (name and month and year) > True > > so both seem to work as expected. That happens only by chance: it seems you now understand the evaluation of "boolean" expressions in Python, so the following should be clear to you: >>> "k" in ("there" + "is" + "a" + "k" + "character" + "somewhere") True >>> "k" in ("there" and "is" and "a" and "k" and "character" and "somewhere") False ciao, lele. -- nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia. lele@metapensiero.it | -- Fortunato Depero, 1929.