Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Grant Edwards Newsgroups: comp.lang.python Subject: Re: Operator precedence problem Date: Mon, 6 Jun 2016 16:51:52 +0000 (UTC) Lines: 32 Message-ID: References: <816c651a-d0ae-4e23-a5b2-72a8f7398468@googlegroups.com> <3ff71354-461a-4635-8d1a-c879243e39a8@googlegroups.com> <2a577a90-3a39-4d8f-90fa-4a00fd4f06a3@googlegroups.com> <1465221421.1069788.629246361.60094337@webmail.messagingengine.com> <87inxmmm67.fsf@elektro.pacujo.net> <87a8iymjel.fsf@elektro.pacujo.net> X-Trace: news.uni-berlin.de FPE5Nz4oJEzeRZLiYDm/sgr3tS7epM2VgTCySOiHnK7Q== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.008 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'expressions': 0.07; 'brackets': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:qwest.net': 0.09; '2016': 0.16; 'nose': 0.16; 'parentheses:': 0.16; 'received:80.91.229.3': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'suppose.': 0.16; 'wrote:': 0.16; '>>>': 0.20; "aren't": 0.22; 'subject:problem': 0.22; 'am,': 0.23; 'code,': 0.23; 'bit': 0.23; 'header:User-Agent:1': 0.26; 'header:X-Complaints-To:1': 0.26; 'chris': 0.26; 'said,': 0.27; 'ronald': 0.29; 'sensible': 0.29; "i'm": 0.30; 'comments': 0.30; 'code': 0.30; 'problem': 0.33; 'case,': 0.34; 'tue,': 0.34; 'could': 0.35; 'clear': 0.35; 'but': 0.36; 'should': 0.36; 'cases': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'received:org': 0.37; 'sure': 0.39; 'to:addr:python.org': 0.40; 'where': 0.40; 'future': 0.60; 'your': 0.60; 'is.': 0.63; 'intent': 0.66; 'readers': 0.66; "they're": 0.66; '"active': 0.84; 'unclear': 0.84; 'beneficial': 0.91; 'edwards': 0.91 X-Injected-Via-Gmane: http://gmane.org/ X-Gmane-NNTP-Posting-Host: 67-130-15-94.dia.static.qwest.net User-Agent: slrn/1.0.2 (Linux) X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: X-Mailman-Original-References: <816c651a-d0ae-4e23-a5b2-72a8f7398468@googlegroups.com> <3ff71354-461a-4635-8d1a-c879243e39a8@googlegroups.com> <2a577a90-3a39-4d8f-90fa-4a00fd4f06a3@googlegroups.com> <1465221421.1069788.629246361.60094337@webmail.messagingengine.com> <87inxmmm67.fsf@elektro.pacujo.net> <87a8iymjel.fsf@elektro.pacujo.net> Xref: csiph.com comp.lang.python:109581 On 2016-06-06, Chris Angelico wrote: > On Tue, Jun 7, 2016 at 1:27 AM, Jon Ribbens > 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) > value = 77 if (x % 2) else (70*7) Just for the record, I don't have any problem at all with any of those parens. I don't think they're at all insulting, they don't slow down comprehension, and they make clear the intent of the writer. I'm not sure I would include all of them if _I_ were writing the code, but in this specific example, I think they're fine. That said, I have seen lots of cases where fully parenthising an expression would harm readability... -- Grant Edwards grant.b.edwards Yow! My nose feels like a at bad Ronald Reagan movie ... gmail.com