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


Groups > comp.lang.python > #65016

Re: 1 > 0 == True -> False

Path csiph.com!usenet.pasdenom.info!gegeweb.org!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@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; 'languages.': 0.04; 'argument': 0.05; 'advocate': 0.07; 'compiler': 0.07; 'mixed': 0.09; 'modulo': 0.09; 'operator,': 0.09; 'part,': 0.09; 'whichever': 0.09; 'cc:addr:python-list': 0.11; 'jan': 0.12; 'assume': 0.14; 'language.': 0.14; 'changes': 0.15; '1:08': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'nesting': 0.16; 'precedence': 0.16; 'roy': 0.16; 'sane': 0.16; 'utterly': 0.16; 'language': 0.16; 'wrote:': 0.18; 'do.': 0.18; '(the': 0.22; 'cc:addr:python.org': 0.22; '31,': 0.24; 'stick': 0.24; 'cc:2**0': 0.24; 'sort': 0.25; 'mention': 0.26; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'am,': 0.29; 'strongly': 0.30; 'message-id:@mail.gmail.com': 0.30; 'code': 0.31; 'getting': 0.31; 'purely': 0.31; 'though.': 0.31; 'languages': 0.32; 'up.': 0.33; 'fri,': 0.33; 'table': 0.34; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'really': 0.36; 'doing': 0.36; 'clear': 0.37; 'that,': 0.38; 'expect': 0.39; 'help,': 0.39; 'read': 0.60; 'everybody': 0.60; 'up,': 0.60; 'today.': 0.61; 'full': 0.61; 'simple': 0.61; "you're": 0.61; 'more': 0.64; 'smith': 0.68; 'article': 0.77; 'protect': 0.79; 'everything.': 0.84; 'or:': 0.84; 'tricky': 0.84; 'subject:True': 0.91; 'that),': 0.91; 'to:none': 0.92; 'differences': 0.93; 'insane': 0.93; 'technique': 0.93
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:cc :content-type; bh=9hcrUX+RyeY8wpDqV10ayvmFvypKIxeWiACrconaqIc=; b=H55LQ23VzcxpGcexCej35iaROFB77weBr2mBR/wZBAdE5xGmRUqqVFfV4+IM+faCG/ qCqdvj8tUPqDGAQvqUobxGfyc8WsNKqNrMrBuAHHG8teDgweWFSTHv2LERsO4XrvqO+z 8vqGNdrD4CU3yXwx6c/Q+2DKT676YyaZXQfVSUSWMs1EP9gMAG8orHkzAfgtYe3/cpwh VckwJ8vQOE3n8YXxUQnw2PzJj0W4Gv5K5LBHn0VFHZYdJJFMsFRsgNIwO7B1KT0dCQce FF7fJ2+fJXFmUHJcPKtbykjzjHH0Lhf7YiSGV69GIgkauI+n6/A62NXEeZWJC/12EjKa FI4g==
MIME-Version 1.0
X-Received by 10.66.160.2 with SMTP id xg2mr14670345pab.23.1391094141977; Thu, 30 Jan 2014 07:02:21 -0800 (PST)
In-Reply-To <roy-582B17.09491630012014@news.panix.com>
References <99b0aa22-5fb3-460a-a080-dacb1c0f2fda@googlegroups.com> <mailman.6129.1391086019.18130.python-list@python.org> <3dcdc95d-5e30-46d3-b558-afedf9723c7c@googlegroups.com> <roy-362954.09085830012014@news.panix.com> <mailman.6143.1391091519.18130.python-list@python.org> <roy-582B17.09491630012014@news.panix.com>
Date Fri, 31 Jan 2014 02:02:21 +1100
Subject Re: 1 > 0 == True -> False
From Chris Angelico <rosuav@gmail.com>
Cc "python-list@python.org" <python-list@python.org>
Content-Type text/plain; charset=UTF-8
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 <https://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 <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.6145.1391094150.18130.python-list@python.org> (permalink)
Lines 42
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1391094150 news.xs4all.nl 2871 [2001:888:2000:d::a6]:45691
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:65016

Show key headers only | View raw


On Fri, Jan 31, 2014 at 1:49 AM, Roy Smith <roy@panix.com> wrote:
> In article <mailman.6143.1391091519.18130.python-list@python.org>,
>  Chris Angelico <rosuav@gmail.com> wrote:
>
>> On Fri, Jan 31, 2014 at 1:08 AM, Roy Smith <roy@panix.com> wrote:
>> > Better than that, do what I do.
>> >
>> > 1) Assume that you don't have the full operator precedence table
>> > memorized and just parenthesize everything.
>>
>> Or:
>>
>> 1a) Assume that you don't have the full operator precedence table
>> memorized and just look it up, for whichever language you're working
>> with today. :)
>
> It's faster to just stick in some extra parens.  Not to mention that it
> makes the code more clear for everybody reading it later.

That won't protect you from getting modulo and truncating-division mixed up. :)

> Operator precedence is a tricky thing.  In part, because it's somewhat
> arbitrary, and in part because it changes from language to language.
> Using "extra" parens to make my meaning clear (to both the compiler and
> other humans who read the code in the future) is a simple technique
> which works in all languages.

It's not arbitrary, but there are differences from language to
language. Yes, parens can help, but I would strongly advocate NOT
using them where it's utterly unambiguous:

x = (2*3)+4 # Pointless!

Whether your language works with * before + (the sane way, doing what
we expect from algebra) or purely left to right (the insane way, but
some languages do do that), the parens are superfluous. Don't use 'em!

But if you work with both PHP and any other language that has a ?:
operator, parenthesizing any nesting of them will avoid a PHP
stupidity. Not that that's really any sort of argument here, though.

ChrisA

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


Thread

1 > 0 == True -> False Thibault Langlois <thibault.langlois@gmail.com> - 2014-01-30 03:36 -0800
  Re: 1 > 0 == True -> False Thomas Mlynarczyk <thomas@mlynarczyk-webdesign.de> - 2014-01-30 12:44 +0100
  Re: 1 > 0 == True -> False Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2014-01-30 13:46 +0200
    Re: 1 > 0 == True -> False Peter Otten <__peter__@web.de> - 2014-01-30 13:04 +0100
      Re: 1 > 0 == True -> False Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2014-01-30 14:08 +0200
  Re:1 > 0 == True -> False Dave Angel <davea@davea.name> - 2014-01-30 07:49 -0500
    Re: 1 > 0 == True -> False Thibault Langlois <thibault.langlois@gmail.com> - 2014-01-30 05:40 -0800
      Re: 1 > 0 == True -> False Chris Angelico <rosuav@gmail.com> - 2014-01-31 00:55 +1100
      Re: 1 > 0 == True -> False Roy Smith <roy@panix.com> - 2014-01-30 09:08 -0500
        Re: 1 > 0 == True -> False Chris Angelico <rosuav@gmail.com> - 2014-01-31 01:18 +1100
          Re: 1 > 0 == True -> False Roy Smith <roy@panix.com> - 2014-01-30 09:49 -0500
            Re: 1 > 0 == True -> False Chris Angelico <rosuav@gmail.com> - 2014-01-31 02:02 +1100
        Re: 1 > 0 == True -> False Devin Jeanpierre <jeanpierreda@gmail.com> - 2014-01-30 06:41 -0800
        Re: 1 > 0 == True -> False Thibault Langlois <thibault.langlois@gmail.com> - 2014-01-30 06:46 -0800
          Re: 1 > 0 == True -> False Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-01-30 17:42 +0000
        Re: 1 > 0 == True -> False Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2014-01-30 16:56 +0200
          Re: 1 > 0 == True -> False Roy Smith <roy@panix.com> - 2014-01-30 10:46 -0800
            Re: 1 > 0 == True -> False Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2014-01-30 22:14 +0200
              Re: 1 > 0 == True -> False Chris Angelico <rosuav@gmail.com> - 2014-01-31 07:25 +1100
        Re: 1 > 0 == True -> False Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-01-30 15:09 +0000
          Re: 1 > 0 == True -> False Rustom Mody <rustompmody@gmail.com> - 2014-01-30 07:34 -0800
          Re: 1 > 0 == True -> False Roy Smith <roy@panix.com> - 2014-01-30 10:53 -0800
            Re: 1 > 0 == True -> False Rustom Mody <rustompmody@gmail.com> - 2014-01-30 19:33 -0800
          Re: 1 > 0 == True -> False Roy Smith <roy@panix.com> - 2014-01-30 10:56 -0800
            Re: 1 > 0 == True -> False Chris Angelico <rosuav@gmail.com> - 2014-01-31 06:03 +1100
              Re: 1 > 0 == True -> False Roy Smith <roy@panix.com> - 2014-01-30 14:09 -0800
                Re: 1 > 0 == True -> False Chris Angelico <rosuav@gmail.com> - 2014-01-31 09:29 +1100
            Re: 1 > 0 == True -> False Ethan Furman <ethan@stoneleaf.us> - 2014-01-30 11:22 -0800
            Re: 1 > 0 == True -> False Chris Angelico <rosuav@gmail.com> - 2014-01-31 06:48 +1100
    Re: 1 > 0 == True -> False Rotwang <sg552@hotmail.co.uk> - 2014-01-30 19:25 +0000
      Re: 1 > 0 == True -> False Dave Angel <davea@davea.name> - 2014-01-30 15:08 -0500
      Re: 1 > 0 == True -> False Chris Angelico <rosuav@gmail.com> - 2014-01-31 07:15 +1100
      Re: 1 > 0 == True -> False Ian Kelly <ian.g.kelly@gmail.com> - 2014-01-30 13:28 -0700
      Re: 1 > 0 == True -> False Chris Angelico <rosuav@gmail.com> - 2014-01-31 07:38 +1100
      Re: 1 > 0 == True -> False Ian Kelly <ian.g.kelly@gmail.com> - 2014-01-30 14:17 -0700
      Re: 1 > 0 == True -> False Chris Angelico <rosuav@gmail.com> - 2014-01-31 08:31 +1100
      Re: 1 > 0 == True -> False Joshua Landau <joshua@landau.ws> - 2014-01-30 23:36 +0000
        Re: 1 > 0 == True -> False Rotwang <sg552@hotmail.co.uk> - 2014-01-31 00:10 +0000
          Removal of iterable unpacking in function calls (was: 1 > 0 == True -> False) Ben Finney <ben+python@benfinney.id.au> - 2014-01-31 11:21 +1100
            Re: Removal of iterable unpacking in function calls Rotwang <sg552@hotmail.co.uk> - 2014-01-31 00:32 +0000
          Re: 1 > 0 == True -> False Joshua Landau <joshua@landau.ws> - 2014-01-31 00:32 +0000
      Re: 1 > 0 == True -> False Chris Angelico <rosuav@gmail.com> - 2014-01-31 11:01 +1100

csiph-web