Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #109579
| Path | csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Chris Angelico <rosuav@gmail.com> |
| Newsgroups | comp.lang.python |
| Subject | Re: Operator precedence problem |
| Date | Tue, 7 Jun 2016 02:21:35 +1000 |
| Lines | 49 |
| Message-ID | <mailman.41.1465230098.2306.python-list@python.org> (permalink) |
| References | <816c651a-d0ae-4e23-a5b2-72a8f7398468@googlegroups.com> <nj0kol$ps$1@ger.gmane.org> <mailman.5.1465112166.2306.python-list@python.org> <3ff71354-461a-4635-8d1a-c879243e39a8@googlegroups.com> <CAMQ2MsFfxF0wSL_y9tSFCoJ1BJ+GVqi2qJLTBzs7+BbGRjW3Bw@mail.gmail.com> <mailman.9.1465142763.2306.python-list@python.org> <2a577a90-3a39-4d8f-90fa-4a00fd4f06a3@googlegroups.com> <1465221421.1069788.629246361.60094337@webmail.messagingengine.com> <mailman.37.1465221424.2306.python-list@python.org> <87inxmmm67.fsf@elektro.pacujo.net> <slrnnlb459.6f8.jon+usenet@sable.unequivocal.co.uk> <87a8iymjel.fsf@elektro.pacujo.net> <slrnnlb5jj.6f8.jon+usenet@sable.unequivocal.co.uk> <CAPTjJmq7vkfZmNndbJn-azX+c8KwjW3uZCzprYdcYU+aM8Ec9A@mail.gmail.com> <mailman.40.1465228656.2306.python-list@python.org> <slrnnlb7pl.6f8.jon+usenet@sable.unequivocal.co.uk> <CAPTjJmrEiUS0KrnpFdwUyd2vtqnd0aAruztxVgG_6zZdMe4a=A@mail.gmail.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| X-Trace | news.uni-berlin.de B8kq/guedOjacrYDr59rtQ/wtKjDLvDS4txl04jB0Hog== |
| Return-Path | <rosuav@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.010 |
| X-Spam-Evidence | '*H*': 0.98; '*S*': 0.00; 'operator': 0.03; '(especially': 0.07; 'expressions': 0.07; 'interpreted': 0.07; 'cc:addr:python-list': 0.09; 'brackets': 0.09; 'python': 0.10; 'interpreter': 0.15; '2016': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'parentheses:': 0.16; 'precedence.': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'suppose.': 0.16; 'wrote:': 0.16; 'obviously': 0.16; 'example.': 0.18; '>>>': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'suggested': 0.20; "aren't": 0.22; 'subject:problem': 0.22; 'am,': 0.23; 'bit': 0.23; 'header:In-Reply-To:1': 0.24; 'example': 0.26; 'chris': 0.26; 'earlier': 0.27; 'figure': 0.27; 'point.': 0.27; 'not.': 0.27; 'used,': 0.27; 'least': 0.27; 'message- id:@mail.gmail.com': 0.27; 'sensible': 0.29; 'sure,': 0.29; 'thread,': 0.29; "i'm": 0.30; 'comments': 0.30; 'code': 0.30; "can't": 0.32; 'point': 0.33; 'usually': 0.33; 'case,': 0.34; 'tue,': 0.34; 'received:google.com': 0.35; 'could': 0.35; 'something': 0.35; 'received:74.125.82': 0.35; "isn't": 0.35; 'but': 0.36; 'should': 0.36; 'there': 0.36; 'subject:: ': 0.37; 'seem': 0.37; 'anything': 0.38; 'why': 0.39; 'sure': 0.39; 'does': 0.39; 'still': 0.40; 'space': 0.40; 'future': 0.60; 'your': 0.60; 'is.': 0.63; 'more': 0.63; 'grab': 0.64; '>>>>>': 0.66; 'readers': 0.66; "they're": 0.66; 'here': 0.66; '"active': 0.84; 'chrisa': 0.84; 'quicker': 0.84; 'unclear': 0.84; 'to:none': 0.91; 'beneficial': 0.91; 'acknowledge': 0.93; 'convinced': 0.93 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:cc; bh=C8eOpZDVFa0Sv46TBYEcm+rdll1PnTGWZlS+TMH6lIc=; b=HP8vtXhv/a6Cf2xxb0lFlXi1X8AXwIjuwW9wUXBPQAKuKJI1Efw2H6kCz6oFyTrfP8 /vFadWOTHLmD92GH50oXLMHBpXamqGQdqVvugv6tXbSEDWZWMbhR35gxjHZdJxP7cm7K 8U/hA6ubQrcagHMEH1erUeqAm8HVtpgeJqvq2HT1Do6BwgVfl9/NHkllZFWotTkmsRvt EkLULsx0vvFuaQ6+TAguAxnDbP8VFbIfbzo2cW4T7iA16s47aKlnRWZhrPoSHMadkNlh 5gR+NZspJrTVeRBFXlf+V3x3EfhqaXtDp2IbKATenk/Ioubb/+3141JlEp31GsJRFlUM yd8Q== |
| X-Google-DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:cc; bh=C8eOpZDVFa0Sv46TBYEcm+rdll1PnTGWZlS+TMH6lIc=; b=PNFnHAPlqH/cUhvPvNyMMvIP8gHMQymkuFnBLK4jbTaqTogtJMCeqvyw8k3D1o++yI EEUD4n+RPGfZ7P5uV6fn7cTI4WgoCDvxPMY1o/87zcD68yMFOhYe8AzGfvKhgr0OZeFH Ao/jhYhcap32234xQiUoIoPONEkv8ds7zbYjUe9hvDRoTLwXmW216uWco60IL87wkf/x MTLCOjBSt+UFAcfWapFJKgnlMJYH17IevSvOUVm0jTdRbnpw4VWgQXqCoH2C0VkDc6w/ pKoZspmddbI/s66euNLqWkJV7vOPGju7MX4ONAuDNYH56jnbli8swWP09pNvW1nhcv5B N7EQ== |
| X-Gm-Message-State | ALyK8tICuUthb0S2e4weqFm7Z3S6PY1X3F8oBe107XMfYY+pp1dTqz+taLWqBt9H06ZfPQhhUmMGSwWgiFZi3Q== |
| X-Received | by 10.28.55.79 with SMTP id e76mr13209295wma.41.1465230096679; Mon, 06 Jun 2016 09:21:36 -0700 (PDT) |
| In-Reply-To | <slrnnlb7pl.6f8.jon+usenet@sable.unequivocal.co.uk> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.22 |
| 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> |
| X-Mailman-Original-Message-ID | <CAPTjJmrEiUS0KrnpFdwUyd2vtqnd0aAruztxVgG_6zZdMe4a=A@mail.gmail.com> |
| X-Mailman-Original-References | <816c651a-d0ae-4e23-a5b2-72a8f7398468@googlegroups.com> <nj0kol$ps$1@ger.gmane.org> <mailman.5.1465112166.2306.python-list@python.org> <3ff71354-461a-4635-8d1a-c879243e39a8@googlegroups.com> <CAMQ2MsFfxF0wSL_y9tSFCoJ1BJ+GVqi2qJLTBzs7+BbGRjW3Bw@mail.gmail.com> <mailman.9.1465142763.2306.python-list@python.org> <2a577a90-3a39-4d8f-90fa-4a00fd4f06a3@googlegroups.com> <1465221421.1069788.629246361.60094337@webmail.messagingengine.com> <mailman.37.1465221424.2306.python-list@python.org> <87inxmmm67.fsf@elektro.pacujo.net> <slrnnlb459.6f8.jon+usenet@sable.unequivocal.co.uk> <87a8iymjel.fsf@elektro.pacujo.net> <slrnnlb5jj.6f8.jon+usenet@sable.unequivocal.co.uk> <CAPTjJmq7vkfZmNndbJn-azX+c8KwjW3uZCzprYdcYU+aM8Ec9A@mail.gmail.com> <mailman.40.1465228656.2306.python-list@python.org> <slrnnlb7pl.6f8.jon+usenet@sable.unequivocal.co.uk> |
| Xref | csiph.com comp.lang.python:109579 |
Show key headers only | View raw
On Tue, Jun 7, 2016 at 2:05 AM, Jon Ribbens <jon+usenet@unequivocal.co.uk> wrote: > On 2016-06-06, Chris Angelico <rosuav@gmail.com> wrote: >> On Tue, Jun 7, 2016 at 1:27 AM, Jon Ribbens >><jon+usenet@unequivocal.co.uk> wrote: >>>>> You should put brackets around expressions when it's at all unclear >>>>> what the meaning is. You could think of them a bit like "active >>>>> comments" I suppose. >>>> >>>> Your code should keep noise to the minimum. >>> >>> Sensible and beneficial comments aren't "noise". >> >> In that case, please never insult the intelligence of your future >> readers by including any of these parentheses: >> >> x = 1 + (2 * 3) > > I'm not sure what your point is. Yes, obviously you can take anything > to ridiculous extremes - that's why I said "sensible". Earlier in this thread, it was suggested that parens always be used, even for this kind of example. >> value = 77 if (x % 2) else (70*7) > > I'm not convinced that one isn't actually a good idea. It does seem > to aid the readability (especially if you space '70 * 7' properly). > If the expressions were any more complex then it would be even more > likely to be a good idea. Hmm, I still think not. But if you want the parens, at least acknowledge that they're not to enforce/remind of operator precedence. >> And if your readers have to figure out what 3**3**3 is interpreted as, >> there should be an interactive interpreter around. Or here - try >> something cute: >> >>>>> 2**2**-1 > > I can't tell now if you're agreeing with me or disagreeing, because > you started out sounding like you were disagreeing but then provided > an example that helps prove my point. My point is that if you're not sure, you grab interactive Python and give it a quick whirl. Usually easier AND quicker than the alternatives. ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Operator precedence problem ICT Ezy <ictezy@gmail.com> - 2016-06-04 23:53 -0700
Re: Operator precedence problem Peter Otten <__peter__@web.de> - 2016-06-05 09:35 +0200
Re: Operator precedence problem ICT Ezy <ictezy@gmail.com> - 2016-06-05 08:05 -0700
Re: Operator precedence problem Uri Even-Chen <uri@speedy.net> - 2016-06-05 19:05 +0300
Re: Operator precedence problem ICT Ezy <ictezy@gmail.com> - 2016-06-05 20:24 -0700
Re: Operator precedence problem Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-06-05 22:46 -0700
Re: Operator precedence problem Random832 <random832@fastmail.com> - 2016-06-06 09:57 -0400
Re: Operator precedence problem Marko Rauhamaa <marko@pacujo.net> - 2016-06-06 17:22 +0300
Re: Operator precedence problem Random832 <random832@fastmail.com> - 2016-06-06 10:35 -0400
Re: Operator precedence problem Marko Rauhamaa <marko@pacujo.net> - 2016-06-06 17:55 +0300
Re: Operator precedence problem Jon Ribbens <jon+usenet@unequivocal.co.uk> - 2016-06-06 15:03 +0000
Re: Operator precedence problem Marko Rauhamaa <marko@pacujo.net> - 2016-06-06 18:22 +0300
Re: Operator precedence problem Jon Ribbens <jon+usenet@unequivocal.co.uk> - 2016-06-06 15:27 +0000
Re: Operator precedence problem Chris Angelico <rosuav@gmail.com> - 2016-06-07 01:57 +1000
Re: Operator precedence problem Jon Ribbens <jon+usenet@unequivocal.co.uk> - 2016-06-06 16:05 +0000
Re: Operator precedence problem Chris Angelico <rosuav@gmail.com> - 2016-06-07 02:21 +1000
Re: Operator precedence problem Jon Ribbens <jon+usenet@unequivocal.co.uk> - 2016-06-06 17:02 +0000
Re: Operator precedence problem Grant Edwards <grant.b.edwards@gmail.com> - 2016-06-06 16:51 +0000
Re: Operator precedence problem Peter Otten <__peter__@web.de> - 2016-06-06 18:38 +0200
Re: Operator precedence problem Steven D'Aprano <steve@pearwood.info> - 2016-06-07 03:07 +1000
Re: Operator precedence problem Random832 <random832@fastmail.com> - 2016-06-06 14:44 -0400
Re: Operator precedence problem Marko Rauhamaa <marko@pacujo.net> - 2016-06-06 21:49 +0300
Re: Operator precedence problem MRAB <python@mrabarnett.plus.com> - 2016-06-06 20:17 +0100
Re: Operator precedence problem Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2016-06-07 11:27 +1200
Re: Operator precedence problem Rustom Mody <rustompmody@gmail.com> - 2016-06-06 10:14 -0700
Re: Operator precedence problem Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-06-06 21:09 +0100
Re: Operator precedence problem Michael Torrie <torriem@gmail.com> - 2016-06-05 17:47 -0600
Re: Operator precedence problem ICT Ezy <ictezy@gmail.com> - 2016-06-05 20:23 -0700
Re: Operator precedence problem Chris Angelico <rosuav@gmail.com> - 2016-06-06 02:24 +1000
Re: Operator precedence problem Peter Pearson <pkpearson@nowhere.invalid> - 2016-06-06 16:58 +0000
Re: Operator precedence problem Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2016-06-07 11:21 +1200
Re: Operator precedence problem Random832 <random832@fastmail.com> - 2016-06-05 13:19 -0400
Re: Operator precedence problem ICT Ezy <ictezy@gmail.com> - 2016-06-05 20:23 -0700
Re: Operator precedence problem Gary Herron <gherron@digipen.edu> - 2016-06-05 00:04 -0700
csiph-web