Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #48108

Re: Eval of expr with 'or' and 'and' within

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 <fabiosantosart@gmail.com>
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; '&gt;&gt;&gt;': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; '&gt;': 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 <kpep0v$spl$8@news.ntua.gr>
References <kpep0v$spl$8@news.ntua.gr>
Date Fri, 14 Jun 2013 11:03:59 +0100
Subject Re: Eval of expr with 'or' and 'and' within
From Fábio Santos <fabiosantosart@gmail.com>
To Νικόλαος Κούρας <support@superhost.gr>
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 <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.3285.1371204248.3114.python-list@python.org> (permalink)
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

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

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.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Eval of expr with 'or' and 'and' within Nick the Gr33k <support@superhost.gr> - 2013-06-14 12:50 +0300
  Re: Eval of expr with 'or' and 'and' within Fábio Santos <fabiosantosart@gmail.com> - 2013-06-14 11:03 +0100
  Re: Eval of expr with 'or' and 'and' within Robert Kern <robert.kern@gmail.com> - 2013-06-14 11:14 +0100
    Re: Eval of expr with 'or' and 'and' within Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-06-14 16:09 +0000
      Re: Eval of expr with 'or' and 'and' within rusi <rustompmody@gmail.com> - 2013-06-14 09:21 -0700
      Re: Eval of expr with 'or' and 'and' within Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-06-14 20:03 +0200
        Re: Eval of expr with 'or' and 'and' within rusi <rustompmody@gmail.com> - 2013-06-14 11:37 -0700
          Re: Eval of expr with 'or' and 'and' within Joshua Landau <joshua.landau.ws@gmail.com> - 2013-06-14 19:47 +0100
      Re: Eval of expr with 'or' and 'and' within alex23 <wuwei23@gmail.com> - 2013-06-14 23:50 -0700
        Re: Eval of expr with 'or' and 'and' within Nick the Gr33k <support@superhost.gr> - 2013-06-15 10:04 +0300
          Re: Eval of expr with 'or' and 'and' within Denis McMahon <denismfmcmahon@gmail.com> - 2013-06-15 07:49 +0000
            Re: Eval of expr with 'or' and 'and' within Nick the Gr33k <support@superhost.gr> - 2013-06-15 10:59 +0300
  Re: Eval of expr with 'or' and 'and' within Grant Edwards <invalid@invalid.invalid> - 2013-06-14 14:49 +0000
    Re: Eval of expr with 'or' and 'and' within Nick the Gr33k <support@superhost.gr> - 2013-06-14 18:16 +0300
      Re: Eval of expr with 'or' and 'and' within Nobody <nobody@nowhere.com> - 2013-06-14 17:42 +0100
        Re: Eval of expr with 'or' and 'and' within Grant Edwards <invalid@invalid.invalid> - 2013-06-14 19:30 +0000
          Re: Eval of expr with 'or' and 'and' within Nobody <nobody@nowhere.com> - 2013-06-15 00:02 +0100
        Re: Eval of expr with 'or' and 'and' within Nick the Gr33k <support@superhost.gr> - 2013-06-15 10:57 +0300
  Re: Eval of expr with 'or' and 'and' within Michael Torrie <torriem@gmail.com> - 2013-06-14 10:29 -0600
    Re: Eval of expr with 'or' and 'and' within Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-06-14 16:49 +0000
      Re: Eval of expr with 'or' and 'and' within Michael Torrie <torriem@gmail.com> - 2013-06-14 11:28 -0600
      Re: Eval of expr with 'or' and 'and' within MRAB <python@mrabarnett.plus.com> - 2013-06-14 18:49 +0100
      Re: Eval of expr with 'or' and 'and' within Chris Angelico <rosuav@gmail.com> - 2013-06-15 03:56 +1000
        Re: Eval of expr with 'or' and 'and' within Grant Edwards <invalid@invalid.invalid> - 2013-06-14 19:33 +0000
          Re: Eval of expr with 'or' and 'and' within Chris Angelico <rosuav@gmail.com> - 2013-06-15 09:56 +1000
        Re: Eval of expr with 'or' and 'and' within Nobody <nobody@nowhere.com> - 2013-06-15 00:09 +0100
          Re: Eval of expr with 'or' and 'and' within Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-06-15 01:34 +0000
            Re: Eval of expr with 'or' and 'and' within Cameron Simpson <cs@zip.com.au> - 2013-06-15 12:03 +1000
              NANs [was Re: Eval of expr with 'or' and 'and' within] Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-06-15 04:22 +0000
            Re: Eval of expr with 'or' and 'and' within Chris Angelico <rosuav@gmail.com> - 2013-06-15 12:21 +1000
      Re: Eval of expr with 'or' and 'and' within Nobody <nobody@nowhere.com> - 2013-06-15 00:06 +0100
        Re: Eval of expr with 'or' and 'and' within MRAB <python@mrabarnett.plus.com> - 2013-06-15 01:26 +0100
  Re: Eval of expr with 'or' and 'and' within Benjamin Kaplan <benjamin.kaplan@case.edu> - 2013-06-14 09:47 -0700
    Re: Eval of expr with 'or' and 'and' within Nick the Gr33k <support@superhost.gr> - 2013-06-14 20:01 +0300
      Re: Eval of expr with 'or' and 'and' within Robert Kern <robert.kern@gmail.com> - 2013-06-14 18:27 +0100
      Re: Eval of expr with 'or' and 'and' within Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2013-06-14 22:05 +0300
      Re: Eval of expr with 'or' and 'and' within Grant Edwards <invalid@invalid.invalid> - 2013-06-14 19:36 +0000
  Re: Eval of expr with 'or' and 'and' within Cameron Simpson <cs@zip.com.au> - 2013-06-15 10:14 +1000
    Re: Eval of expr with 'or' and 'and' within Nick the Gr33k <support@superhost.gr> - 2013-06-15 11:20 +0300
      Re: Eval of expr with 'or' and 'and' within Lele Gaifax <lele@metapensiero.it> - 2013-06-15 11:48 +0200
        Re: Eval of expr with 'or' and 'and' within Nick the Gr33k <support@superhost.gr> - 2013-06-15 16:24 +0300
        Re: Eval of expr with 'or' and 'and' within Nick the Gr33k <support@superhost.gr> - 2013-06-15 16:28 +0300

csiph-web