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.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'operator': 0.03; 'anyway.': 0.05; 'string.': 0.05; 'detect': 0.07; "subject:' ": 0.07; 'string': 0.09; 'logic': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'thread': 0.14; 'dismiss': 0.16; 'track.': 0.16; 'year)': 0.16; 'wrote:': 0.18; 'value.': 0.19; 'examples': 0.20; 'seems': 0.21; '>>>': 0.22; 'cc:addr:python.org': 0.22; '>>>': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; '>': 0.26; 'post': 0.26; 'header:In-Reply-To:1': 0.27; 'character': 0.29; 'returned': 0.30; 'message-id:@mail.gmail.com': 0.30; 'explained': 0.31; 'this.': 0.32; 'know.': 0.32; 'another': 0.32; 'subject:with': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'replies': 0.36; 'returning': 0.36; 'words,': 0.36; 'doing': 0.36; 'skip:& 10': 0.38; 'previous': 0.38; 'that,': 0.38; 'short': 0.38; 'does': 0.39; 'how': 0.40; 'expression': 0.60; 'skip:y 20': 0.60; 'first': 0.61; 'within': 0.65; 'here': 0.66; 'circuit': 0.84; 'irrelevant': 0.84; 'to:addr:support': 0.84; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=hV9KNLDtkmbo0W5hE07aoJUIj5nE5g3E8bUM4Sa+7E8=; b=jDZZ2MXCL8TAowN/c/WXtwKi4AwwWgCX77qMZ/ZIuP1Gt6/5yI4xfUhKhhw6oaTsIW cEAiZYbhDDuWquWWR8hpp04pu3CEdqtMU04VCoSucCKXZgoQFI1Cg0UG8bX+4nlAAKGV U11Jc461QcknQMzH9FX57HCHs+f9OdZp+YR5c+z7AySMaIRf88KlI+l1bvrdchaY/P77 fHGNFMhC67G2jRqb+5WaVfpbdEbrdBGQvZfMeOSGjdJ7+vX/08lBkMr3N6co0apb21/D VmaWsTwffxLM32djW+xex+Fc3zaa2bWy3A/RS7eNSB3ZSgkd1LBK9NGjwZ3z05AATp7l lS3A== MIME-Version: 1.0 X-Received: by 10.220.109.66 with SMTP id i2mr646340vcp.51.1371204239508; Fri, 14 Jun 2013 03:03:59 -0700 (PDT) In-Reply-To: References: Date: Fri, 14 Jun 2013 11:03:59 +0100 Subject: Re: Eval of expr with 'or' and 'and' within From: =?ISO-8859-1?Q?F=E1bio_Santos?= To: =?ISO-8859-7?B?zenq/Ovh7/Igyu/98eHy?= Content-Type: multipart/alternative; boundary=001a11c2165c9c489d04df1a5d53 Cc: python-list@python.org 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: 83 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1371204250 news.xs4all.nl 16003 [2001:888:2000:d::a6]:50338 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:48108 --001a11c2165c9c489d04df1a5d53 Content-Type: text/plain; charset=ISO-8859-1 On 14 Jun 2013 10:59, "Nick the Gr33k" wrote: > > I started another thread because the last one was !@#$'ed up by irrelevant replies and was difficult to jeep track. > > >>> name="abcd" > >>> month="efgh" > >>> year="ijkl" > > >>> print(name or month or year) > abcd > > Can understand that, it takes the first string out of the 3 strings that has a truthy value. > > >>> print("k" in (name and month and year)) > True > > No clue. since the expression in parenthesis returns 'abcd' how can 'k' contained within 'abcd' ? > > >>> print(name and month and year) > ijkl > > Seems here is returning the last string out of 3 strings, but have no clue why Python doing this. > > >>> print("k" in (name and month and year)) > True > >>> > > yes, since expression returns 'ijkl', then the in operator can detect the 'k' character within the returned string. > > This is all iw ant to know. You have been explained with both words, links and examples and now you dismiss the previous post because it was "difficult to jeep track"? Anyway. Search for "short circuit logic". Short circuit logic is why python does it that way. --001a11c2165c9c489d04df1a5d53 Content-Type: text/html; charset=ISO-8859-1


On 14 Jun 2013 10:59, "Nick the Gr33k" <support@superhost.gr> wrote:
>
> I started another thread because the last one was !@#$'ed up by irrelevant replies and was difficult to jeep track.
>
> >>> name="abcd"
> >>> month="efgh"
> >>> year="ijkl"
>
> >>> print(name or month or year)
> abcd
>
> Can understand that, it takes the first string out of the 3 strings that has a truthy value.
>
> >>> print("k" in (name and month and year))
> True
>
> No clue. since the expression in parenthesis returns 'abcd' how can 'k' contained within 'abcd' ?
>
> >>> print(name and month and year)
> ijkl
>
> Seems here is returning the last string out of 3 strings, but have no clue why Python doing this.
>
> >>> print("k" in (name and month and year))
> True
> >>>
>
> yes, since expression returns 'ijkl', then the in operator can detect the 'k' character within the returned string.
>
> This is all iw ant to know.

You have been explained with both words, links and examples and now you dismiss the previous post because it was "difficult to jeep track"?

Anyway. Search for "short circuit logic". Short circuit logic is why python does it that way.

--001a11c2165c9c489d04df1a5d53--