Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #109579
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: Operator precedence problem |
| Date | 2016-06-07 02:21 +1000 |
| Message-ID | <mailman.41.1465230098.2306.python-list@python.org> (permalink) |
| References | (12 earlier) <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> |
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