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


Groups > comp.lang.python > #48180

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 <bsk16@case.edu>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.005
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'value,': 0.04; 'string.': 0.05; "subject:' ": 0.07; 'false,': 0.09; 'received:209.85.219': 0.09; 'type,': 0.09; 'python': 0.11; '"and"': 0.16; '"michael': 0.16; '"or"': 0.16; 'backwards': 0.16; 'boolean': 0.16; 'clause,': 0.16; 'integer.': 0.16; 'nick': 0.16; 'to:name:python list': 0.16; 'year)': 0.16; 'wrote:': 0.18; 'value.': 0.19; '>>>': 0.22; 'email addr:gmail.com&gt;': 0.22; '&gt;': 0.26; 'header:In-Reply-To:1': 0.27; 'correct': 0.29; 'am,': 0.29; 'message-id:@mail.gmail.com': 0.30; 'this.': 0.32; 'quite': 0.32; "i'd": 0.34; 'subject:with': 0.35; 'received:209.85': 0.35; 'something': 0.35; 'received:google.com': 0.35; '14,': 0.36; 'false': 0.36; "didn't": 0.36; 'turn': 0.37; 'received:209': 0.37; 'skip:& 10': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'expression': 0.60; 'skip:\xc2 10': 0.60; 'then,': 0.60; 'break': 0.61; 'new': 0.61; 'first': 0.61; 'day.': 0.63; 'finally': 0.65; 'evaluate': 0.72; '2013': 0.98
X-Google-DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:x-gm-message-state; bh=Z7Jq0o8UNdZt7pNxTPpbAdh3gz1/dZ6vl33ER4iFVs0=; b=hIzWhNfdXJ2IjfN/6I3IYhKlkL3AjGTFGFoAhhnzRIQq8Pz41Nqw813zHsZMUdhnA2 1I0NgZPrnZU7klTyi76GL8viNMBfhBCGF79iATAsc0NnOmb/w2om1k7f/W0O16rPG71Y jt9cU15JOsCpwJAvhOAUQO5/2/yaOIpz/SfdFKoLbiE7FsY6xR7HXCnZY7GE5Q8jvMZC D8UJEeOyNxSIJUJity8J6r2X3A+1f+hGNoF4/cqIocJmKkOdYSM7Lofvk1Ol+ezJaxyZ Ay5HPgM6dWQjiShSjZDXG8TEjzKIWCAJm6gZHA1Zv7EItNCloLPqjOAYOW90aqsVoxVS KnlA==
X-Received by 10.60.39.104 with SMTP id o8mr2030535oek.14.1371228467769; Fri, 14 Jun 2013 09:47:47 -0700 (PDT)
MIME-Version 1.0
X-Received by 10.60.39.104 with SMTP id o8mr2030533oek.14.1371228467704; Fri, 14 Jun 2013 09:47:47 -0700 (PDT)
In-Reply-To <51BB44E5.9010201@gmail.com>
References <kpep0v$spl$8@news.ntua.gr> <51BB44E5.9010201@gmail.com>
Date Fri, 14 Jun 2013 09:47:47 -0700
Subject Re: Eval of expr with 'or' and 'and' within
From Benjamin Kaplan <benjamin.kaplan@case.edu>
To Python List <python-list@python.org>
Content-Type multipart/alternative; boundary=089e013a032ab9418404df2001e7
X-Gm-Message-State ALoCoQmU1f3ZRi7oWinyKJJOUQVZua06IXTnLKwYBnixgZ5Voy4XqjkDXWw1TiBalmJlgasxy0h8jru4Sy1UhkMZrgVR0ChCU8daC8EY9lFWWEswil8Q0mwHawJ17bVjNoK77qlgsa6H40g0W4mN6nqnnzmtsA/0qw==
X-Junkmail-Whitelist YES (by domain whitelist at mpv2.tis.cwru.edu)
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.3317.1371228471.3114.python-list@python.org> (permalink)
Lines 58
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1371228471 news.xs4all.nl 15977 [2001:888:2000:d::a6]:57071
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:48180

Show key headers only | View raw


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

On Jun 14, 2013 9:34 AM, "Michael Torrie" <torriem@gmail.com> wrote:
>
> On 06/14/2013 03:50 AM, Nick the Gr33k wrote:
> >  >>> print(name or month or year)
> > abcd
> >  >>> print(name and month and year)
> > ijkl
>
> Interesting.  I'd have thought a boolean expression would return True or
> False, not a string.  Learn something new every day.
>
>
>

Python didn't have a Boolean type for quite some time (2.2?). Until then,
True and False were ints. Since every object had a Boolean value, you
didn't need to turn the result into an integer. 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.

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