Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #11094 > unrolled thread
| Started by | Yingjie Lan <lanyjie@yahoo.com> |
|---|---|
| First post | 2011-08-09 23:05 -0700 |
| Last post | 2011-08-11 00:55 +0100 |
| Articles | 20 on this page of 159 — 34 participants |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: allow line break at operators Yingjie Lan <lanyjie@yahoo.com> - 2011-08-09 23:05 -0700
Re: allow line break at operators Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-08-10 18:32 +1000
Re: allow line break at operators Chris Angelico <rosuav@gmail.com> - 2011-08-10 09:39 +0100
Re: allow line break at operators Dan Sommers <dan@tombstonezero.net> - 2011-08-10 09:56 +0000
Re: allow line break at operators Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-08-11 00:44 +1000
Re: allow line break at operators Chris Angelico <rosuav@gmail.com> - 2011-08-10 11:26 +0100
Re: allow line break at operators Duncan Booth <duncan.booth@invalid.invalid> - 2011-08-10 12:25 +0000
Re: allow line break at operators Chris Angelico <rosuav@gmail.com> - 2011-08-10 13:42 +0100
Re: allow line break at operators Yingjie Lan <lanyjie@yahoo.com> - 2011-08-10 05:58 -0700
Re: allow line break at operators Chris Angelico <rosuav@gmail.com> - 2011-08-10 15:45 +0100
Re: allow line break at operators Yingjie Lan <lanyjie@yahoo.com> - 2011-08-10 06:19 -0700
Re: allow line break at operators Chris Angelico <rosuav@gmail.com> - 2011-08-10 16:56 +0100
Re: allow line break at operators Seebs <usenet-nospam@seebs.net> - 2011-08-10 17:55 +0000
Re: allow line break at operators Ben Finney <ben+python@benfinney.id.au> - 2011-08-11 07:51 +1000
Re: allow line break at operators Chris Angelico <rosuav@gmail.com> - 2011-08-10 23:42 +0100
Re: allow line break at operators Neil Cerutti <neilc@norwich.edu> - 2011-08-11 14:40 +0000
Re: Python & Sullivan Tim Chase <python.list@tim.thechases.com> - 2011-08-10 18:26 -0500
Re: Python & Sullivan Ben Finney <ben+python@benfinney.id.au> - 2011-08-11 10:57 +1000
Re: Python & Sullivan Chris Angelico <rosuav@gmail.com> - 2011-08-11 00:54 +0100
Re: allow line break at operators Seebs <usenet-nospam@seebs.net> - 2011-08-11 04:59 +0000
Re: allow line break at operators Ben Finney <ben+python@benfinney.id.au> - 2011-08-11 15:56 +1000
Re: allow line break at operators Seebs <usenet-nospam@seebs.net> - 2011-08-11 21:19 +0000
Re: allow line break at operators Chris Angelico <rosuav@gmail.com> - 2011-08-12 00:58 +0100
Re: allow line break at operators Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-08-12 11:40 +1000
Re: allow line break at operators Chris Angelico <rosuav@gmail.com> - 2011-08-12 08:09 +0100
Re: allow line break at operators Neil Cerutti <neilc@norwich.edu> - 2011-08-12 12:57 +0000
Re: allow line break at operators Thomas Rachel <nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915@spamschutz.glglgl.de> - 2011-08-12 14:54 +0200
Re: allow line break at operators Tim Roberts <timr@probo.com> - 2011-08-14 22:22 -0700
Re: allow line break at operators Ben Finney <ben+python@benfinney.id.au> - 2011-08-12 18:59 +1000
Re: allow line break at operators Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-08-12 20:40 +1000
Re: allow line break at operators Ben Finney <ben+python@benfinney.id.au> - 2011-08-12 21:16 +1000
Re: allow line break at operators Seebs <usenet-nospam@seebs.net> - 2011-08-12 16:33 +0000
Re: allow line break at operators Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-08-11 22:29 +1000
Re: allow line break at operators Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-08-11 22:40 +1000
Re: allow line break at operators Seebs <usenet-nospam@seebs.net> - 2011-08-11 21:19 +0000
Re: allow line break at operators Seebs <usenet-nospam@seebs.net> - 2011-08-11 21:19 +0000
Re: allow line break at operators Ethan Furman <ethan@stoneleaf.us> - 2011-08-11 15:43 -0700
Re: allow line break at operators Seebs <usenet-nospam@seebs.net> - 2011-08-12 06:34 +0000
Re: allow line break at operators Chris Angelico <rosuav@gmail.com> - 2011-08-12 08:20 +0100
Re: allow line break at operators rantingrick <rantingrick@gmail.com> - 2011-08-12 08:33 -0700
Re: allow line break at operators Chris Angelico <rosuav@gmail.com> - 2011-08-12 20:52 +0100
Re: allow line break at operators Seebs <usenet-nospam@seebs.net> - 2011-08-12 16:33 +0000
Re: allow line break at operators Ben Finney <ben+python@benfinney.id.au> - 2011-08-12 20:39 +1000
Re: allow line break at operators Chris Rebert <clp2@rebertia.com> - 2011-08-12 10:03 -0700
Re: allow line break at operators Seebs <usenet-nospam@seebs.net> - 2011-08-12 18:37 +0000
Re: allow line break at operators Seebs <usenet-nospam@seebs.net> - 2011-08-12 16:33 +0000
Re: allow line break at operators Chris Angelico <rosuav@gmail.com> - 2011-08-12 21:01 +0100
Re: allow line break at operators Seebs <usenet-nospam@seebs.net> - 2011-08-12 21:06 +0000
Re: allow line break at operators rantingrick <rantingrick@gmail.com> - 2011-08-12 08:26 -0700
Re: allow line break at operators Seebs <usenet-nospam@seebs.net> - 2011-08-12 16:33 +0000
Re: allow line break at operators rantingrick <rantingrick@gmail.com> - 2011-08-12 10:57 -0700
Re: allow line break at operators Chris Angelico <rosuav@gmail.com> - 2011-08-12 21:09 +0100
Re: allow line break at operators Seebs <usenet-nospam@seebs.net> - 2011-08-12 21:06 +0000
Re: allow line break at operators Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-08-13 08:39 +1000
Re: allow line break at operators Chris Angelico <rosuav@gmail.com> - 2011-08-12 23:50 +0100
Re: allow line break at operators Ben Finney <ben+python@benfinney.id.au> - 2011-08-13 09:19 +1000
Re: allow line break at operators Tim Chase <python.list@tim.thechases.com> - 2011-08-12 18:53 -0500
Re: allow line break at operators Seebs <usenet-nospam@seebs.net> - 2011-08-13 00:39 +0000
Re: allow line break at operators Ben Finney <ben+python@benfinney.id.au> - 2011-08-13 10:57 +1000
Re: allow line break at operators Seebs <usenet-nospam@seebs.net> - 2011-08-13 02:34 +0000
Re: allow line break at operators rantingrick <rantingrick@gmail.com> - 2011-08-13 18:50 -0700
Re: allow line break at operators rantingrick <rantingrick@gmail.com> - 2011-08-13 19:07 -0700
Re: allow line break at operators rantingrick <rantingrick@gmail.com> - 2011-08-13 18:59 -0700
Re: allow line break at operators Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-08-14 17:10 +1000
Re: allow line break at operators Seebs <usenet-nospam@seebs.net> - 2011-08-14 08:07 +0000
Re: allow line break at operators Ben Finney <ben+python@benfinney.id.au> - 2011-08-14 19:25 +1000
Re: allow line break at operators Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-08-15 00:26 +1000
Re: allow line break at operators Roy Smith <roy@panix.com> - 2011-08-14 11:35 -0400
Re: allow line break at operators Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-08-15 03:24 +1000
Re: Re: allow line break at operators Dave Angel <davea@ieee.org> - 2011-08-14 17:46 -0400
Re: allow line break at operators Roy Smith <roy@panix.com> - 2011-08-14 18:46 -0400
Re: allow line break at operators Chris Angelico <rosuav@gmail.com> - 2011-08-15 00:02 +0100
Re: allow line break at operators Chris Angelico <rosuav@gmail.com> - 2011-08-14 16:39 +0100
Re: allow line break at operators Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-08-15 03:26 +1000
Re: allow line break at operators Seebs <usenet-nospam@seebs.net> - 2011-08-14 19:01 +0000
Re: allow line break at operators Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-08-15 11:54 +1000
Re: allow line break at operators Chris Rebert <clp2@rebertia.com> - 2011-08-14 19:10 -0700
Re: allow line break at operators Seebs <usenet-nospam@seebs.net> - 2011-08-15 04:28 +0000
Re: allow line break at operators Tim Chase <python.list@tim.thechases.com> - 2011-08-15 06:40 -0500
Re: allow line break at operators Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-08-15 23:30 +1000
Re: allow line break at operators Seebs <usenet-nospam@seebs.net> - 2011-08-15 16:32 +0000
Re: allow line break at operators alex23 <wuwei23@gmail.com> - 2011-08-15 21:13 -0700
Re: allow line break at operators rantingrick <rantingrick@gmail.com> - 2011-08-15 21:37 -0700
Re: allow line break at operators alex23 <wuwei23@gmail.com> - 2011-08-15 23:49 -0700
Re: allow line break at operators rantingrick <rantingrick@gmail.com> - 2011-08-16 11:56 -0700
Re: allow line break at operators Seebs <usenet-nospam@seebs.net> - 2011-08-15 04:28 +0000
Re: allow line break at operators Terry Reedy <tjreedy@udel.edu> - 2011-08-15 03:31 -0400
Re: allow line break at operators rantingrick <rantingrick@gmail.com> - 2011-08-15 14:21 -0700
Re: allow line break at operators Chris Angelico <rosuav@gmail.com> - 2011-08-15 09:27 +0100
Re: allow line break at operators Chris Angelico <rosuav@gmail.com> - 2011-08-14 09:34 +0100
Re: allow line break at operators Ben Finney <ben+python@benfinney.id.au> - 2011-08-14 19:27 +1000
Re: allow line break at operators Ethan Furman <ethan@stoneleaf.us> - 2011-08-14 03:51 -0700
Re: allow line break at operators Chris Angelico <rosuav@gmail.com> - 2011-08-14 12:59 +0100
Re: allow line break at operators Teemu Likonen <tlikonen@iki.fi> - 2011-08-14 12:46 +0300
Re: allow line break at operators Seebs <usenet-nospam@seebs.net> - 2011-08-14 19:01 +0000
Re: allow line break at operators Seebs <usenet-nospam@seebs.net> - 2011-08-14 19:01 +0000
Re: allow line break at operators Chris Rebert <clp2@rebertia.com> - 2011-08-14 01:44 -0700
Re: allow line break at operators Teemu Likonen <tlikonen@iki.fi> - 2011-08-16 07:04 +0300
Re: allow line break at operators rantingrick <rantingrick@gmail.com> - 2011-08-13 19:18 -0700
Re: allow line break at operators Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2011-08-13 13:19 +1200
Re: allow line break at operators Johann Hibschman <jhibschman+usenet@gmail.com> - 2011-08-15 08:27 -0500
Re: allow line break at operators Roy Smith <roy@panix.com> - 2011-08-15 09:41 -0400
Re: allow line break at operators Chris Angelico <rosuav@gmail.com> - 2011-08-15 15:16 +0100
Re: allow line break at operators Roy Smith <roy@panix.com> - 2011-08-15 20:34 -0400
Re: allow line break at operators Chris Angelico <rosuav@gmail.com> - 2011-08-16 01:37 +0100
Re: allow line break at operators Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-08-16 00:28 +1000
Re: allow line break at operators Chris Angelico <rosuav@gmail.com> - 2011-08-15 15:42 +0100
Re: allow line break at operators Roy Smith <roy@panix.com> - 2011-08-15 20:30 -0400
Re: allow line break at operators Seebs <usenet-nospam@seebs.net> - 2011-08-16 00:39 +0000
Re: allow line break at operators Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2011-08-16 12:43 +1200
Re: allow line break at operators Seebs <usenet-nospam@seebs.net> - 2011-08-15 16:32 +0000
Re: allow line break at operators Ethan Furman <ethan@stoneleaf.us> - 2011-08-12 13:35 -0700
Re: allow line break at operators Seebs <usenet-nospam@seebs.net> - 2011-08-12 21:06 +0000
Re: allow line break at operators Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-08-13 08:03 +1000
Re: allow line break at operators Seebs <usenet-nospam@seebs.net> - 2011-08-12 22:14 +0000
Re: allow line break at operators Ben Finney <ben+python@benfinney.id.au> - 2011-08-13 08:36 +1000
Re: allow line break at operators Terry Reedy <tjreedy@udel.edu> - 2011-08-12 20:15 -0400
Re: allow line break at operators Seebs <usenet-nospam@seebs.net> - 2011-08-13 00:44 +0000
Re: allow line break at operators rantingrick <rantingrick@gmail.com> - 2011-08-13 18:25 -0700
Re: allow line break at operators Ben Finney <ben+python@benfinney.id.au> - 2011-08-13 08:12 +1000
RE: allow line break at operators "Prasad, Ramit" <ramit.prasad@jpmorgan.com> - 2011-08-16 15:51 -0400
RE: allow line break at operators "Prasad, Ramit" <ramit.prasad@jpmorgan.com> - 2011-08-16 15:26 -0400
Re: allow line break at operators Seebs <usenet-nospam@seebs.net> - 2011-08-16 20:19 +0000
Re: allow line break at operators Chris Angelico <rosuav@gmail.com> - 2011-08-16 21:05 +0100
Re: allow line break at operators Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-08-11 10:32 +1000
Re: allow line break at operators Chris Angelico <rosuav@gmail.com> - 2011-08-11 01:47 +0100
Re: allow line break at operators Seebs <usenet-nospam@seebs.net> - 2011-08-11 04:59 +0000
Re: allow line break at operators Yingjie Lan <lanyjie@yahoo.com> - 2011-08-10 19:52 -0700
Re: allow line break at operators Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-08-11 14:18 +1000
Re: allow line break at operators Chris Rebert <clp2@rebertia.com> - 2011-08-11 00:50 -0700
Re: allow line break at operators Vito 'ZeD' De Tullio <zak.mc.kraken@libero.it> - 2011-08-11 12:21 +0200
Re: allow line break at operators Yingjie Lan <lanyjie@yahoo.com> - 2011-08-10 19:58 -0700
Re: allow line break at operators Chris Rebert <clp2@rebertia.com> - 2011-08-10 21:16 -0700
Re: allow line break at operators Chris Rebert <clp2@rebertia.com> - 2011-08-10 22:07 -0700
Re: allow line break at operators Chris Angelico <rosuav@gmail.com> - 2011-08-11 09:24 +0100
Re: allow line break at operators MRAB <python@mrabarnett.plus.com> - 2011-08-11 14:03 +0100
Re: [Python-ideas] allow line break at operators Matt Joiner <anacrolix@gmail.com> - 2011-08-12 00:28 +1000
Re: [Python-ideas] allow line break at operators Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-08-12 12:32 +1000
Re: [Python-ideas] allow line break at operators Jakob Bowyer <jkbbwr@gmail.com> - 2011-08-11 16:42 +0100
Re: [Python-ideas] allow line break at operators Daniel Greenfeld <pydanny@gmail.com> - 2011-08-11 10:04 -0700
Re: [Python-ideas] allow line break at operators Paul Colomiets <paul@colomiets.name> - 2011-08-11 22:17 +0300
Re: [Python-ideas] allow line break at operators Devin Jeanpierre <jeanpierreda@gmail.com> - 2011-08-11 17:06 -0400
Re: [Python-ideas] allow line break at operators Devin Jeanpierre <jeanpierreda@gmail.com> - 2011-08-11 17:29 -0400
Re: [Python-ideas] allow line break at operators Jim Jewett <jimjjewett@gmail.com> - 2011-08-11 17:39 -0400
Re: [Python-ideas] allow line break at operators Devin Jeanpierre <jeanpierreda@gmail.com> - 2011-08-11 18:29 -0400
Re: [Python-ideas] allow line break at operators Matt Joiner <anacrolix@gmail.com> - 2011-09-02 15:33 +1000
Re: [Python-ideas] allow line break at operators Roy Smith <roy@panix.com> - 2011-09-03 12:59 -0400
Re: [Python-ideas] allow line break at operators "Stephen J. Turnbull" <stephen@xemacs.org> - 2011-09-02 16:28 +0900
Re: [Python-ideas] allow line break at operators Guido van Rossum <guido@python.org> - 2011-09-02 12:30 -0700
Re: [Python-ideas] allow line break at operators "Stephen J. Turnbull" <stephen@xemacs.org> - 2011-09-03 13:38 +0900
Re: [Python-ideas] allow line break at operators "Stephen J. Turnbull" <stephen@xemacs.org> - 2011-09-03 15:10 +0900
Re: [Python-ideas] allow line break at operators Terry Reedy <tjreedy@udel.edu> - 2011-09-03 15:01 -0400
Re: [Python-ideas] allow line break at operators ron3200 <ron3200@gmail.com> - 2011-09-04 10:22 -0500
Re: allow line break at operators rantingrick <rantingrick@gmail.com> - 2011-09-04 11:08 -0700
Re: allow line break at operators Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-08-11 00:37 +1000
Re: allow line break at operators Chris Angelico <rosuav@gmail.com> - 2011-08-10 16:13 +0100
Re: allow line break at operators Ian Kelly <ian.g.kelly@gmail.com> - 2011-08-10 09:16 -0600
Re: allow line break at operators Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-08-11 09:32 +1000
Re: allow line break at operators Chris Angelico <rosuav@gmail.com> - 2011-08-11 00:55 +0100
Page 6 of 8 — ← Prev page 1 2 3 4 5 [6] 7 8 Next page →
| From | Johann Hibschman <jhibschman+usenet@gmail.com> |
|---|---|
| Date | 2011-08-15 08:27 -0500 |
| Message-ID | <u1o62lyg5zl.fsf@ld-chrate28.citadelgroup.com> |
| In reply to | #11303 |
Chris Angelico <rosuav@gmail.com> writes: > Why is left-to-right inherently more logical than > multiplication-before-addition? Why is it more logical than > right-to-left? And why is changing people's expectations more logical > than fulfilling them? Python uses the + and - symbols to mean addition > and subtraction for good reason. Let's not alienate the mathematical > mind by violating this rule. It would be far safer to go the other way > and demand parentheses on everything. I'm a clearly a fool for allowing myself to be drawn into this thread, but I've been playing a lot recently with the APL-derivative language J, which uses a right-to-left operator precendence rule. Pragmatically, this is because J defines roughly a bajillion operators, and it would be impossible to remember the precendence of them all, but it makes sense in its own way. If you read "3 * 10 + 7", using right-to-left, you get "three times something". Then you read more and you get "three times (ten plus something)." And finally, you get "3*(10+7)". The prefix gives the continuation for the rest of the calculation; no matter what you substitute for X in "3*X", you will always just evaluate X, then multply it by 3. Likewise, for "3*10+X", no matter what X is, you know you'll add 10 and multiply by 3. This took me a while to get used to, but it's definitely a nice property. Not much to do with python, but I do like the syntax enough that I've implemented my own toy evaluator for J-like expressions in python, to get around the verbosity of some bits of numpy. Regards, Johann
[toc] | [prev] | [next] | [standalone]
| From | Roy Smith <roy@panix.com> |
|---|---|
| Date | 2011-08-15 09:41 -0400 |
| Message-ID | <roy-D85560.09413315082011@news.panix.com> |
| In reply to | #11303 |
In article <mailman.2233.1313179799.1164.python-list@python.org>,
Chris Angelico <rosuav@gmail.com> wrote:
> Python uses the + and - symbols to mean addition
> and subtraction for good reason. Let's not alienate the mathematical
> mind by violating this rule.
Computer programming languages follow math conventions only in the most
vague ways. For example, standard math usage dictates that addition is
commutative. While this is true for adding integers, it's certainly not
true for adding strings (in any language which supports string addition).
Where to draw the line between math and programming languages is not an
easy question.
> It would be far safer to go the other way
> and demand parentheses on everything.
Demand, no, but sometimes it's a good idea. I've been writing computer
programs for close to 40 years, and I still have no clue what most of
the order of operations is. It's just not worth investing the brain
cells to remember such trivia (especially since the details change from
language to language). Beyond remembering the (apparently) universal
rule that {*, /} bind tighter than {+, -}, I pretty much just punt on
everything else and put in extra parens everywhere.
It's not the most efficient way to write code, and probably doesn't even
result in the prettiest code. But it sure does eliminate those
face-palm moments at the end of a long debugging session when you
realize that somebody got it wrong.
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2011-08-15 15:16 +0100 |
| Message-ID | <mailman.10.1313417818.27778.python-list@python.org> |
| In reply to | #11459 |
On Mon, Aug 15, 2011 at 2:41 PM, Roy Smith <roy@panix.com> wrote:
> Demand, no, but sometimes it's a good idea. I've been writing computer
> programs for close to 40 years, and I still have no clue what most of
> the order of operations is. It's just not worth investing the brain
> cells to remember such trivia (especially since the details change from
> language to language). Beyond remembering the (apparently) universal
> rule that {*, /} bind tighter than {+, -}, I pretty much just punt on
> everything else and put in extra parens everywhere.
>
Understandable. I go the other way, though, and keep an operator
precedence table for each language handy; often, what I'm after is not
"which one binds more tightly", but "what's the symbol for modulo",
which is also (usually) on that same table. Or: "Blasted PHP, which
operators have precedence between || and or?" which is easy to forget.
And you're right about the details changing from language to language,
hence the operators table *for each language*. But most languages
follow fairly sane rules, and tend to come up with pretty much the
same ordering.
ChrisA
[toc] | [prev] | [next] | [standalone]
| From | Roy Smith <roy@panix.com> |
|---|---|
| Date | 2011-08-15 20:34 -0400 |
| Message-ID | <roy-EAD9B4.20340315082011@news.panix.com> |
| In reply to | #11460 |
In article <mailman.10.1313417818.27778.python-list@python.org>, Chris Angelico <rosuav@gmail.com> wrote: > Or: "Blasted PHP, which > operators have precedence between || and or?" which is easy to forget. > > And you're right about the details changing from language to language, > hence the operators table *for each language*. But most languages > follow fairly sane rules How dare you use the words "PHP" and "sane" in two adjoining paragraphs!
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2011-08-16 01:37 +0100 |
| Message-ID | <mailman.31.1313455044.27778.python-list@python.org> |
| In reply to | #11484 |
On Tue, Aug 16, 2011 at 1:34 AM, Roy Smith <roy@panix.com> wrote: > In article <mailman.10.1313417818.27778.python-list@python.org>, > Chris Angelico <rosuav@gmail.com> wrote: > >> Or: "Blasted PHP, which >> operators have precedence between || and or?" which is easy to forget. >> >> And you're right about the details changing from language to language, >> hence the operators table *for each language*. But most languages >> follow fairly sane rules > > How dare you use the words "PHP" and "sane" in two adjoining paragraphs! By separating them with the word "most". ChrisA
[toc] | [prev] | [next] | [standalone]
| From | Steven D'Aprano <steve+comp.lang.python@pearwood.info> |
|---|---|
| Date | 2011-08-16 00:28 +1000 |
| Message-ID | <4e492d08$0$30003$c3e8da3$5496439d@news.astraweb.com> |
| In reply to | #11459 |
Roy Smith wrote: > Computer programming languages follow math conventions only in the most > vague ways. For example, standard math usage dictates that addition is > commutative. While this is true for adding integers, it's certainly not > true for adding strings (in any language which supports string addition). Not quite true for maths either, at least in principle. I'm not aware of any number types where addition is non-commutative, but subtraction is noncommutative even for integers, and noncommutative multiplication is quite common (e.g. matrix multiplication). And of course, once you start using floating point numbers, you can't assume commutativity: >>> 0.1 + 0.7 + 0.3 == 0.3 + 0.7 + 0.1 False I'm reminded of this quote from John Baez: "The real numbers are the dependable breadwinner of the family, the complete ordered field we all rely on. The complex numbers are a slightly flashier but still respectable younger brother: not ordered, but algebraically complete. The quaternions, being noncommutative, are the eccentric cousin who is shunned at important family gatherings. But the octonions are the crazy old uncle nobody lets out of the attic: they are nonassociative." (And don't even ask about the sedenions...) -- Steven
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2011-08-15 15:42 +0100 |
| Message-ID | <mailman.11.1313419331.27778.python-list@python.org> |
| In reply to | #11461 |
On Mon, Aug 15, 2011 at 3:28 PM, Steven D'Aprano
<steve+comp.lang.python@pearwood.info> wrote:
> And of course, once you start using floating point numbers, you can't assume
> commutativity:
>
>>>> 0.1 + 0.7 + 0.3 == 0.3 + 0.7 + 0.1
> False
>
This isn't because programming languages fail to follow mathematics;
it's because floating point numbers do not represent real numbers.
Python doesn't support substring removal using the subtraction
operator, but I'd have to say that floats more closely parallel
strings and other high level objects than they do mathematical reals.
If Python treated __sub__(str,str) as str.replace(str,"") then:
>>> "hello world" + "asdfqwer" - "d"
"hello worlasfqwer"
>>> "hello world" - "d" + "asdfqwer"
"hello worlasdfqwer"
Nobody would expect strings to behave mathematically with subtraction,
because negatives don't make sense. Even sets don't quite work,
although they're closer:
>>> set("asdf")-set("test")
{'a', 'd', 'f'}
There's no way, in a set, to show a negative reference to 't' and 'e'.
In theory you could do this with dictionaries or collections.Counter,
but subtracting a Counter from a Counter doesn't produce negative
numbers either. No, these constructs do not subtract algebraically,
and I do not think it would be any improvement to the language if they
did.
ChrisA
[toc] | [prev] | [next] | [standalone]
| From | Roy Smith <roy@panix.com> |
|---|---|
| Date | 2011-08-15 20:30 -0400 |
| Message-ID | <roy-8B2F4C.20305215082011@news.panix.com> |
| In reply to | #11461 |
In article <4e492d08$0$30003$c3e8da3$5496439d@news.astraweb.com>, Steven D'Aprano <steve+comp.lang.python@pearwood.info> wrote: > I'm reminded of this quote from John Baez: > > "The real numbers are the dependable breadwinner of the family, the complete > ordered field we all rely on. The complex numbers are a slightly flashier > but still respectable younger brother: not ordered, but algebraically > complete. The quaternions, being noncommutative, are the eccentric cousin > who is shunned at important family gatherings. But the octonions are the > crazy old uncle nobody lets out of the attic: they are nonassociative." Wow, at first glance, I mis-parsed that name as "Joan Baez". Had me really confused for a moment.
[toc] | [prev] | [next] | [standalone]
| From | Seebs <usenet-nospam@seebs.net> |
|---|---|
| Date | 2011-08-16 00:39 +0000 |
| Message-ID | <slrnj4jf1d.nvr.usenet-nospam@guild.seebs.net> |
| In reply to | #11483 |
On 2011-08-16, Roy Smith <roy@panix.com> wrote: > In article <4e492d08$0$30003$c3e8da3$5496439d@news.astraweb.com>, > Steven D'Aprano <steve+comp.lang.python@pearwood.info> wrote: >> I'm reminded of this quote from John Baez: >> "The real numbers are the dependable breadwinner of the family, the complete >> ordered field we all rely on. The complex numbers are a slightly flashier >> but still respectable younger brother: not ordered, but algebraically >> complete. The quaternions, being noncommutative, are the eccentric cousin >> who is shunned at important family gatherings. But the octonions are the >> crazy old uncle nobody lets out of the attic: they are nonassociative." > Wow, at first glance, I mis-parsed that name as "Joan Baez". Had me > really confused for a moment. Would it have been that much weirder than Hedy Lamarr? -s -- Copyright 2011, all wrongs reversed. Peter Seebach / usenet-nospam@seebs.net http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated! I am not speaking for my employer, although they do rent some of my opinions.
[toc] | [prev] | [next] | [standalone]
| From | Gregory Ewing <greg.ewing@canterbury.ac.nz> |
|---|---|
| Date | 2011-08-16 12:43 +1200 |
| Message-ID | <9atsqeF442U1@mid.individual.net> |
| In reply to | #11461 |
Steven D'Aprano wrote: > I'm reminded of this quote from John Baez: > > "...But the octonions are the > crazy old uncle nobody lets out of the attic: they are nonassociative." > > (And don't even ask about the sedenions...) Aren't they the ones that mutilate cattle and abduct people? -- Greg
[toc] | [prev] | [next] | [standalone]
| From | Seebs <usenet-nospam@seebs.net> |
|---|---|
| Date | 2011-08-15 16:32 +0000 |
| Message-ID | <slrnj4ihli.1gj.usenet-nospam@guild.seebs.net> |
| In reply to | #11459 |
On 2011-08-15, Roy Smith <roy@panix.com> wrote:
> Demand, no, but sometimes it's a good idea. I've been writing computer
> programs for close to 40 years, and I still have no clue what most of
> the order of operations is. It's just not worth investing the brain
> cells to remember such trivia (especially since the details change from
> language to language). Beyond remembering the (apparently) universal
> rule that {*, /} bind tighter than {+, -}, I pretty much just punt on
> everything else and put in extra parens everywhere.
>
> It's not the most efficient way to write code, and probably doesn't even
> result in the prettiest code. But it sure does eliminate those
> face-palm moments at the end of a long debugging session when you
> realize that somebody got it wrong.
Wholehearted agreement. It is conceivable for me to misremember precedence.
I am pretty reliable at recognizing which things are in which parens.
So I use them even in obvious cases:
foo + (3 * 4)
Never regretted that. Yes, it's extra typing, a little, but it prevents a
whole category of bugs.
-s
--
Copyright 2011, all wrongs reversed. Peter Seebach / usenet-nospam@seebs.net
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
I am not speaking for my employer, although they do rent some of my opinions.
[toc] | [prev] | [next] | [standalone]
| From | Ethan Furman <ethan@stoneleaf.us> |
|---|---|
| Date | 2011-08-12 13:35 -0700 |
| Message-ID | <mailman.2234.1313180382.1164.python-list@python.org> |
| In reply to | #11295 |
Chris Angelico wrote: > Incidentally, in the original expression, it would be slightly more > sane to write it as: > > a = x + y) * z > > borrowing from the musical concept that a repeat sign with no > corresponding begin-repeat means to repeat from the beginning. But > both of these violate XKCD 859. Argh! ;) ~Ethan~
[toc] | [prev] | [next] | [standalone]
| From | Seebs <usenet-nospam@seebs.net> |
|---|---|
| Date | 2011-08-12 21:06 +0000 |
| Message-ID | <slrnj4b5ic.1pjc.usenet-nospam@guild.seebs.net> |
| In reply to | #11295 |
On 2011-08-12, rantingrick <rantingrick@gmail.com> wrote:
> On Aug 12, 11:33?am, Seebs <usenet-nos...@seebs.net> wrote:
>> My brain has quirks. ?Some people call them defects, some don't, but it
>> really doesn't matter; there are things about which my brain is just plain
>> unreliable and I rely moderately heavily on extra visual cues to reduce
>> the frequency with which I get things wrong when skimming.
> I think that really boils down to you refusing to open your eyes up to
> new ways of doing things.
You think that, then? Okay.
> You are clutching the past and it is taking
> you down with it.
I see. This is a brilliant new theory. I will further explore the notion
that actually my brain is 100% normal with no limitations except that I have
used languages with braces. Doubtless this will prove illuminating.
>> No, because the *LANE BOUNDARIES* would move.
> The "lane boundaries" will also move whilst reading code that uses the
> indent/dedent paradigm. Are you honestly telling me that you will skip
> over a four spaced dedent without seeing it however you can easily
> spot a single closing brace and instantly "know" which corresponding
> opener brace to which it referrers without looking, and counting, and
> wasting time? Sorry, i just don't believe you.
Nope, not telling you that. Here's my example:
if foo:
blah
blah
blah
if bar:
moreblah
moreblah
if quux:
typingisboring
typingisboring
typingisboring
moreblah
moreblah
if baz:
somuchblah
somuchblah
somuchblah
somuchblah
somuchblah
somuchblah
somuchblah
somuchblah
abitmoreblah
It's not easy for me to be sure, looking at something roughly like that,
what's being closed and what isn't. If I have braces, I can tell how many
things are being closed. I like that. It makes me happy.
>> I propose we extend it to expression processing in general. ?Instead
>> of writing
>> ? ? ? ? a = (x + y) * z
>> let's just write
>> ? ? ? ? a = (x + y * z
> I'm glad you brought this up! How about this instead:
> a = x + y * z
> ...where the calculation is NOT subject to operator precedence? I
> always hated using parenthesis in mathematical calculations. All math
> should resolve in a linear fashion. 3+3*2 should always be 12 and NOT
> 9!
Doesn't matter. At some point, somewhere, it would become desireable
to introduce precedence with (), at which point, it is quite possible
that the trailing ) would be redundant, so why not omit it?
> I am not trying to discredit you simply by disagreeing with you.
No, but you're certainly being insulting.
> I have offered facts as to why significant indention is far superior to
> braces and yet you continue to use the same emotionally charged babble
> in your defense.
Facts:
Pry your lips from Ritchie's left teet and stop slurping
that "brace" milk; because it is polluting your mind!
Emotionally charged babble:
My brain has quirks. Some people call them defects, some don't,
but it really doesn't matter; there are things about which
my brain is just plain unreliable and I rely moderately
heavily on extra visual cues to reduce the frequency with
which I get things wrong when skimming.
> When you offer some real facts then i will give then
> just consideration, until then i will "try" to enlighten you of the
> merits of significant indentation.
Well played!
-s
--
Copyright 2011, all wrongs reversed. Peter Seebach / usenet-nospam@seebs.net
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
I am not speaking for my employer, although they do rent some of my opinions.
[toc] | [prev] | [next] | [standalone]
| From | Steven D'Aprano <steve+comp.lang.python@pearwood.info> |
|---|---|
| Date | 2011-08-13 08:03 +1000 |
| Message-ID | <4e45a345$0$29976$c3e8da3$5496439d@news.astraweb.com> |
| In reply to | #11291 |
Seebs wrote: > On 2011-08-12, rantingrick <rantingrick@gmail.com> wrote: >> What is with you guys and this need to have your hand held to read >> code. > > Good question! Great to see that the helpful and welcoming community > is living up to its reputation. Please don't feed the troll. Responding to Rick's standard obnoxious posts is like wrestling with a pig -- you get tired and filthy, you never accomplish anything useful, and after a while, you realise that the pig is enjoying it. Save yourself a lot of aggravation and kill-file him now. -- Steven
[toc] | [prev] | [next] | [standalone]
| From | Seebs <usenet-nospam@seebs.net> |
|---|---|
| Date | 2011-08-12 22:14 +0000 |
| Message-ID | <slrnj4b9c7.1t7p.usenet-nospam@guild.seebs.net> |
| In reply to | #11312 |
On 2011-08-12, Steven D'Aprano <steve+comp.lang.python@pearwood.info> wrote: > Please don't feed the troll. Responding to Rick's standard obnoxious posts > is like wrestling with a pig -- you get tired and filthy, you never > accomplish anything useful, and after a while, you realise that the pig is > enjoying it. Save yourself a lot of aggravation and kill-file him now. You know... I think I just realized where a big part of my misperception of the Python community was. Which is that until todayish, I had not realized that he was regarded as a troll by the rest of the community. But now that a couple of people have told me this, I am a lot more comfortable referring to the Python community in general as "welcoming". I sometimes enjoy trying to extract information from people like that, but I will respect the preferences of the actually-helpful people and drop that line of inquiry. :) -s -- Copyright 2011, all wrongs reversed. Peter Seebach / usenet-nospam@seebs.net http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated! I am not speaking for my employer, although they do rent some of my opinions.
[toc] | [prev] | [next] | [standalone]
| From | Ben Finney <ben+python@benfinney.id.au> |
|---|---|
| Date | 2011-08-13 08:36 +1000 |
| Message-ID | <87y5yyfeat.fsf@benfinney.id.au> |
| In reply to | #11314 |
Seebs <usenet-nospam@seebs.net> writes: > I sometimes enjoy trying to extract information from people like that, > but I will respect the preferences of the actually-helpful people and > drop that line of inquiry. :) Much appreciated, thank you :-) -- \ “It is well to remember that the entire universe, with one | `\ trifling exception, is composed of others.” —John Andrew Holmes | _o__) | Ben Finney
[toc] | [prev] | [next] | [standalone]
| From | Terry Reedy <tjreedy@udel.edu> |
|---|---|
| Date | 2011-08-12 20:15 -0400 |
| Message-ID | <mailman.2247.1313194568.1164.python-list@python.org> |
| In reply to | #11314 |
On 8/12/2011 6:14 PM, Seebs wrote:
I am responding to your whole line of posts.
I have been indenting code neatly for at least 32 years whenever the
language I used allowed it. Just over 14 years ago, when Python was an
obscure little known or used languge, I adopted it *because* it dropped
all the redundant bracket noise and looked to me like 'executable
pseudocode', as I explained (with an unfortunate misspelling) in
https://groups.google.com/group/comp.lang.python/msg/cc25701a283a3f68
Indentation is part of that. Python-with-brackets would, to me, be
something different -- sure, derived from Python, but not the same.
I do not need for you to adopt and use Python to validate my choice. If
you like it fine, welcome. If not, have fun with something else. I said
that over a decade when this same discussion took place, and I say it
now. Different brains are different. I do not care which of us is in the
majority in which population.
As I and others also pointed out over a decade ago, anyone is free to
add insignificant comment braces (but keep that private, please) or,
more sensibly, commented dedents to help the reader keep track of indent
level.
for...
for ...
if ...
for ...
if ...
[50 more lines of code]
#end outer if
[more code]
--
Terry Jan Reedy
[toc] | [prev] | [next] | [standalone]
| From | Seebs <usenet-nospam@seebs.net> |
|---|---|
| Date | 2011-08-13 00:44 +0000 |
| Message-ID | <slrnj4bi5k.2407.usenet-nospam@guild.seebs.net> |
| In reply to | #11322 |
On 2011-08-13, Terry Reedy <tjreedy@udel.edu> wrote: > I have been indenting code neatly for at least 32 years whenever the > language I used allowed it. Just over 14 years ago, when Python was an > obscure little known or used languge, I adopted it *because* it dropped > all the redundant bracket noise and looked to me like 'executable > pseudocode', as I explained (with an unfortunate misspelling) in > https://groups.google.com/group/comp.lang.python/msg/cc25701a283a3f68 > Indentation is part of that. Python-with-brackets would, to me, be > something different -- sure, derived from Python, but not the same. Fair enough. > I do not need for you to adopt and use Python to validate my choice. If > you like it fine, welcome. If not, have fun with something else. If this were among my options, it's probably what I'd do. It is what I do for things where I get a choice of languages. FWIW, yes, I spec machines with ECC memory whenever I can. I am a big fan of "redundant" data that can detect likely errors. -s -- Copyright 2011, all wrongs reversed. Peter Seebach / usenet-nospam@seebs.net http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated! I am not speaking for my employer, although they do rent some of my opinions.
[toc] | [prev] | [next] | [standalone]
| From | rantingrick <rantingrick@gmail.com> |
|---|---|
| Date | 2011-08-13 18:25 -0700 |
| Message-ID | <c1e2e54e-4c8a-4e2a-8a20-cc95bc1e1863@g9g2000yqb.googlegroups.com> |
| In reply to | #11312 |
On Aug 12, 5:03 pm, Steven D'Aprano <steve
+comp.lang.pyt...@pearwood.info> wrote:
> Responding to Rick's standard {EDIT} posts
> is like wrestling with a {EDIT}
> [...]
> Save yourself a lot of aggravation and kill-file him now.
Kindly allow Walter E. Kurtz to shine some light on this situation:
""" Pig after pig, cow after cow, village after village, army after
army. And they call me an assassin. What do you call it when the
assassins accuse the assassin? They lie.. they lie and we have to be
merciful for those who lie. Those nabobs. I hate them. How I hate
them..."""
[toc] | [prev] | [next] | [standalone]
| From | Ben Finney <ben+python@benfinney.id.au> |
|---|---|
| Date | 2011-08-13 08:12 +1000 |
| Message-ID | <874o1mgtys.fsf@benfinney.id.au> |
| In reply to | #11291 |
Seebs <usenet-nospam@seebs.net> writes: > On 2011-08-12, rantingrick <rantingrick@gmail.com> wrote: > > What is with you guys and this need to have your hand held to read > > code. > > Good question! Great to see that the helpful and welcoming community > is living up to its reputation. Please be aware that the particular person to whom you're responding is decidedly not part of the helpful and welcoming community here. > Man, you really love pushing them buttons, don't you? > > You don't understand a thing. Therefore... there is no such thing, > anyone who experiences life differently from you needs to be insulted? If you're interested, check the forum's archives for a thorough history of what the helpful and welcoming community say about him. You'll find we pretty much agree with your assessment. -- \ “Generally speaking, the errors in religion are dangerous; | `\ those in philosophy only ridiculous.” —David Hume, _A Treatise | _o__) of Human Nature_, 1739 | Ben Finney
[toc] | [prev] | [next] | [standalone]
Page 6 of 8 — ← Prev page 1 2 3 4 5 [6] 7 8 Next page →
Back to top | Article view | comp.lang.python
csiph-web