Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #16993 > unrolled thread
| Started by | Eelco Hoogendoorn <hoogendoorn.eelco@gmail.com> |
|---|---|
| First post | 2011-12-12 00:44 +0100 |
| Last post | 2011-12-12 13:02 -0500 |
| Articles | 11 on this page of 91 — 21 participants |
Back to article view | Back to comp.lang.python
Verbose and flexible args and kwargs syntax Eelco Hoogendoorn <hoogendoorn.eelco@gmail.com> - 2011-12-12 00:44 +0100
Re: Verbose and flexible args and kwargs syntax Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-12-12 01:11 +0000
Re: Verbose and flexible args and kwargs syntax Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2011-12-12 21:09 +1300
Re: Verbose and flexible args and kwargs syntax Terry Reedy <tjreedy@udel.edu> - 2011-12-12 10:36 -0500
Re: Verbose and flexible args and kwargs syntax Nick Dokos <nicholas.dokos@hp.com> - 2011-12-12 10:55 -0500
Re: Verbose and flexible args and kwargs syntax Arnaud Delobelle <arnodel@gmail.com> - 2011-12-12 16:15 +0000
Re: Verbose and flexible args and kwargs syntax Chris Angelico <rosuav@gmail.com> - 2011-12-13 03:16 +1100
Re: Verbose and flexible args and kwargs syntax Chris Angelico <rosuav@gmail.com> - 2011-12-13 03:19 +1100
Re: Verbose and flexible args and kwargs syntax Eelco <hoogendoorn.eelco@gmail.com> - 2011-12-12 04:21 -0800
Re: Verbose and flexible args and kwargs syntax Ian Kelly <ian.g.kelly@gmail.com> - 2011-12-12 11:09 -0700
Re: Verbose and flexible args and kwargs syntax Eelco <hoogendoorn.eelco@gmail.com> - 2011-12-12 10:17 -0800
Re: Verbose and flexible args and kwargs syntax Ian Kelly <ian.g.kelly@gmail.com> - 2011-12-12 11:35 -0700
Re: Verbose and flexible args and kwargs syntax Eelco <hoogendoorn.eelco@gmail.com> - 2011-12-12 10:51 -0800
Re: Verbose and flexible args and kwargs syntax Ian Kelly <ian.g.kelly@gmail.com> - 2011-12-12 17:34 -0700
Re: Verbose and flexible args and kwargs syntax Eelco <hoogendoorn.eelco@gmail.com> - 2011-12-13 00:31 -0800
Re: Verbose and flexible args and kwargs syntax Eelco <hoogendoorn.eelco@gmail.com> - 2011-12-12 11:05 -0800
Re: Verbose and flexible args and kwargs syntax Eelco <hoogendoorn.eelco@gmail.com> - 2011-12-12 11:20 -0800
Re: Verbose and flexible args and kwargs syntax alex23 <wuwei23@gmail.com> - 2011-12-12 15:54 -0800
Re: Verbose and flexible args and kwargs syntax Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-12-13 02:43 +0000
Re: Verbose and flexible args and kwargs syntax Chris Angelico <rosuav@gmail.com> - 2011-12-13 14:08 +1100
Re: Verbose and flexible args and kwargs syntax Ian Kelly <ian.g.kelly@gmail.com> - 2011-12-12 21:52 -0700
Re: Verbose and flexible args and kwargs syntax Eelco <hoogendoorn.eelco@gmail.com> - 2011-12-13 01:15 -0800
Re: Verbose and flexible args and kwargs syntax Eelco <hoogendoorn.eelco@gmail.com> - 2011-12-13 01:50 -0800
Re: Verbose and flexible args and kwargs syntax Arnaud Delobelle <arnodel@gmail.com> - 2011-12-13 10:15 +0000
Re: Verbose and flexible args and kwargs syntax Eelco <hoogendoorn.eelco@gmail.com> - 2011-12-13 02:39 -0800
Re: Verbose and flexible args and kwargs syntax Eelco <hoogendoorn.eelco@gmail.com> - 2011-12-13 02:46 -0800
Re: Verbose and flexible args and kwargs syntax Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-12-13 11:28 +0000
Re: Verbose and flexible args and kwargs syntax Eelco <hoogendoorn.eelco@gmail.com> - 2011-12-13 04:19 -0800
Re: Verbose and flexible args and kwargs syntax Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-12-13 11:13 +0000
Re: Verbose and flexible args and kwargs syntax Eelco <hoogendoorn.eelco@gmail.com> - 2011-12-13 04:47 -0800
Re: Verbose and flexible args and kwargs syntax Chris Angelico <rosuav@gmail.com> - 2011-12-14 00:14 +1100
Re: Verbose and flexible args and kwargs syntax Eelco <hoogendoorn.eelco@gmail.com> - 2011-12-13 05:35 -0800
Re: Verbose and flexible args and kwargs syntax "OKB (not okblacke)" <brenNOSPAMbarn@NObrenSPAMbarn.net> - 2011-12-12 19:45 +0000
Re: Verbose and flexible args and kwargs syntax Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2011-12-12 12:59 +0200
Re: Verbose and flexible args and kwargs syntax Eelco <hoogendoorn.eelco@gmail.com> - 2011-12-12 03:22 -0800
Re: Verbose and flexible args and kwargs syntax Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2011-12-12 13:46 +0200
Re: Verbose and flexible args and kwargs syntax Eelco <hoogendoorn.eelco@gmail.com> - 2011-12-12 03:18 -0800
Re: Verbose and flexible args and kwargs syntax Terry Reedy <tjreedy@udel.edu> - 2011-12-12 10:39 -0500
Re: Verbose and flexible args and kwargs syntax Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2011-12-12 18:52 +0200
Re: Verbose and flexible args and kwargs syntax Eelco <hoogendoorn.eelco@gmail.com> - 2011-12-12 09:29 -0800
Re: Verbose and flexible args and kwargs syntax Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2011-12-12 20:09 +0200
% is not an operator [was Re: Verbose and flexible args and kwargs syntax] Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-12-14 03:18 +0000
Re: % is not an operator [was Re: Verbose and flexible args and kwargs syntax] Eelco <hoogendoorn.eelco@gmail.com> - 2011-12-13 23:49 -0800
Re: % is not an operator [was Re: Verbose and flexible args and kwargs syntax] Arnaud Delobelle <arnodel@gmail.com> - 2011-12-14 11:55 +0000
Re: % is not an operator [was Re: Verbose and flexible args and kwargs syntax] Eelco <hoogendoorn.eelco@gmail.com> - 2011-12-14 04:33 -0800
Re: % is not an operator [was Re: Verbose and flexible args and kwargs syntax] Arnaud Delobelle <arnodel@gmail.com> - 2011-12-14 16:13 +0000
Re: % is not an operator [was Re: Verbose and flexible args and kwargs syntax] Eelco <hoogendoorn.eelco@gmail.com> - 2011-12-14 09:15 -0800
Re: % is not an operator [was Re: Verbose and flexible args and kwargs syntax] rusi <rustompmody@gmail.com> - 2011-12-14 19:43 -0800
Re: % is not an operator [was Re: Verbose and flexible args and kwargs syntax] Eelco <hoogendoorn.eelco@gmail.com> - 2011-12-15 01:44 -0800
Re: % is not an operator [was Re: Verbose and flexible args and kwargs syntax] rusi <rustompmody@gmail.com> - 2011-12-15 02:56 -0800
Re: % is not an operator [was Re: Verbose and flexible args and kwargs syntax] Eelco <hoogendoorn.eelco@gmail.com> - 2011-12-15 03:37 -0800
Re: % is not an operator [was Re: Verbose and flexible args and kwargs syntax] Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2011-12-14 10:56 +0200
Re: % is not an operator [was Re: Verbose and flexible args and kwargs syntax] Eelco <hoogendoorn.eelco@gmail.com> - 2011-12-14 02:09 -0800
Re: % is not an operator [was Re: Verbose and flexible args and kwargs syntax] Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2011-12-14 14:22 +0200
Re: % is not an operator [was Re: Verbose and flexible args and kwargs syntax] Eelco <hoogendoorn.eelco@gmail.com> - 2011-12-14 04:41 -0800
Re: % is not an operator [was Re: Verbose and flexible args and kwargs syntax] Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-12-14 12:38 +0000
Re: % is not an operator [was Re: Verbose and flexible args and kwargs syntax] Eelco <hoogendoorn.eelco@gmail.com> - 2011-12-14 05:29 -0800
Re: % is not an operator [was Re: Verbose and flexible args and kwargs syntax] Chris Angelico <rosuav@gmail.com> - 2011-12-15 00:39 +1100
Re: % is not an operator [was Re: Verbose and flexible args and kwargs syntax] Ian Kelly <ian.g.kelly@gmail.com> - 2011-12-14 08:45 -0700
Re: % is not an operator [was Re: Verbose and flexible args and kwargs syntax] Terry Reedy <tjreedy@udel.edu> - 2011-12-14 15:57 -0500
Re: % is not an operator [was Re: Verbose and flexible args and kwargs syntax] rusi <rustompmody@gmail.com> - 2011-12-14 03:47 -0800
Re: % is not an operator [was Re: Verbose and flexible args and kwargs syntax] Chris Angelico <rosuav@gmail.com> - 2011-12-14 22:53 +1100
Re: % is not an operator [was Re: Verbose and flexible args and kwargs syntax] Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2011-12-14 15:09 +0200
Re: % is not an operator [was Re: Verbose and flexible args and kwargs syntax] Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-12-14 12:32 +0000
Re: % is not an operator [was Re: Verbose and flexible args and kwargs syntax] Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2011-12-14 15:21 +0200
Re: % is not an operator [was Re: Verbose and flexible args and kwargs syntax] Robert Kern <robert.kern@gmail.com> - 2011-12-15 10:47 +0000
Re: % is not an operator [was Re: Verbose and flexible args and kwargs syntax] Eelco <hoogendoorn.eelco@gmail.com> - 2011-12-15 02:59 -0800
Re: % is not an operator [was Re: Verbose and flexible args and kwargs syntax] alex23 <wuwei23@gmail.com> - 2011-12-15 18:14 -0800
Re: % is not an operator [was Re: Verbose and flexible args and kwargs syntax] MRAB <python@mrabarnett.plus.com> - 2011-12-16 02:58 +0000
Re: % is not an operator [was Re: Verbose and flexible args and kwargs syntax] Eelco <hoogendoorn.eelco@gmail.com> - 2011-12-16 02:36 -0800
Re: % is not an operator [was Re: Verbose and flexible args and kwargs syntax] Chris Angelico <rosuav@gmail.com> - 2011-12-16 16:01 +1100
Re: % is not an operator [was Re: Verbose and flexible args and kwargs syntax] alex23 <wuwei23@gmail.com> - 2011-12-15 21:30 -0800
Re: % is not an operator [was Re: Verbose and flexible args and kwargs syntax] Eelco <hoogendoorn.eelco@gmail.com> - 2011-12-16 02:25 -0800
Re: % is not an operator [was Re: Verbose and flexible args and kwargs syntax] rusi <rustompmody@gmail.com> - 2011-12-16 09:38 -0800
Re: % is not an operator [was Re: Verbose and flexible args and kwargs syntax] Eelco <hoogendoorn.eelco@gmail.com> - 2011-12-16 11:40 -0800
Re: % is not an operator [was Re: Verbose and flexible args and kwargs syntax] Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2011-12-17 12:49 +1300
Re: % is not an operator [was Re: Verbose and flexible args and kwargs syntax] Eelco <hoogendoorn.eelco@gmail.com> - 2011-12-16 16:00 -0800
Re: % is not an operator [was Re: Verbose and flexible args and kwargs syntax] Roy Smith <roy@panix.com> - 2011-12-16 19:03 -0500
Re: % is not an operator [was Re: Verbose and flexible args and kwargs syntax] Grant Edwards <invalid@invalid.invalid> - 2011-12-17 20:02 +0000
Re: % is not an operator [was Re: Verbose and flexible args and kwargs syntax] Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-12-17 00:54 +0000
Re: % is not an operator [was Re: Verbose and flexible args and kwargs syntax] David Robinow <drobinow@gmail.com> - 2011-12-16 21:11 -0500
Re: % is not an operator [was Re: Verbose and flexible args and kwargs syntax] Chris Angelico <rosuav@gmail.com> - 2011-12-15 21:58 +1100
Re: % is not an operator [was Re: Verbose and flexible args and kwargs syntax] rusi <rustompmody@gmail.com> - 2011-12-15 03:04 -0800
Re: % is not an operator [was Re: Verbose and flexible args and kwargs syntax] Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2011-12-15 14:48 +0200
Re: % is not an operator [was Re: Verbose and flexible args and kwargs syntax] Terry Reedy <tjreedy@udel.edu> - 2011-12-15 18:15 -0500
Re: % is not an operator Paul Rudin <paul.nospam@rudin.co.uk> - 2011-12-14 09:43 +0000
Re: Verbose and flexible args and kwargs syntax Nick Dokos <nicholas.dokos@hp.com> - 2011-12-12 12:58 -0500
Re: Verbose and flexible args and kwargs syntax Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2011-12-14 11:04 +0200
Re: Verbose and flexible args and kwargs syntax gene heskett <gheskett@wdtv.com> - 2011-12-12 12:46 -0500
Re: Verbose and flexible args and kwargs syntax Dave Angel <d@davea.name> - 2011-12-12 13:04 -0500
Re: Verbose and flexible args and kwargs syntax Nick Dokos <nicholas.dokos@hp.com> - 2011-12-12 13:02 -0500
Page 5 of 5 — ← Prev page 1 2 3 4 [5]
| From | David Robinow <drobinow@gmail.com> |
|---|---|
| Date | 2011-12-16 21:11 -0500 |
| Subject | Re: % is not an operator [was Re: Verbose and flexible args and kwargs syntax] |
| Message-ID | <mailman.3760.1324087888.27778.python-list@python.org> |
| In reply to | #17397 |
On Fri, Dec 16, 2011 at 7:54 PM, Steven D'Aprano <steve+comp.lang.python@pearwood.info> wrote: > On Fri, 16 Dec 2011 11:40:11 -0800, Eelco wrote: > >> On 16 dec, 18:38, rusi <rustompm...@gmail.com> wrote: >>> On Dec 16, 3:25 pm, Eelco <hoogendoorn.ee...@gmail.com> wrote: >>> >>> > Pseudo-backwards compatibility with other languages, I couldnt not >>> > care less for. >>> >>> Double negations n Goedelian situations have interesting implications >>> (tho here its triple) >> >> Heh. Well at least my extra (unintended) negation is semantically >> consistent with the actual english usage of the phrase, which omits the >> negation completely :). (I could care less) > > Oh please. "I could care less" is not English. That's American. > > Here in Australia, we follow the English practice of saying that we > couldn't care less. Well the phrase is still somewhat controversial in the US. I never heard it until age 19 (in 1966) and have always been somewhat disdainful of those using it. But it appears to be hopeless. http://articles.boston.com/2010-10-24/lifestyle/29303907_1_care-peeves-decades
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2011-12-15 21:58 +1100 |
| Subject | Re: % is not an operator [was Re: Verbose and flexible args and kwargs syntax] |
| Message-ID | <mailman.3667.1323946713.27778.python-list@python.org> |
| In reply to | #17203 |
On Thu, Dec 15, 2011 at 9:47 PM, Robert Kern <robert.kern@gmail.com> wrote: > 42 = 2 mod 5 > 2 = 42 mod 5 It might make more sense to programmers if you think of it as written: 42 = 2, mod 5 2 = 42, mod 5 ChrisA
[toc] | [prev] | [next] | [standalone]
| From | rusi <rustompmody@gmail.com> |
|---|---|
| Date | 2011-12-15 03:04 -0800 |
| Subject | Re: % is not an operator [was Re: Verbose and flexible args and kwargs syntax] |
| Message-ID | <4f2f6742-b1b2-4605-8004-b6aa431b8513@k5g2000pra.googlegroups.com> |
| In reply to | #17260 |
On Dec 15, 3:58 pm, Chris Angelico <ros...@gmail.com> wrote: > On Thu, Dec 15, 2011 at 9:47 PM, Robert Kern <robert.k...@gmail.com> wrote: > > 42 = 2 mod 5 > > 2 = 42 mod 5 > > It might make more sense to programmers if you think of it as written: > > 42 = 2, mod 5 > 2 = 42, mod 5 > > ChrisA For the record I should say that the guy who taught me abstract algebra, said about as much: He said that the notation a == b mod n should be written as a ==n b (read the == as 3 horizontal lines and the n as a subscript)
[toc] | [prev] | [next] | [standalone]
| From | Jussi Piitulainen <jpiitula@ling.helsinki.fi> |
|---|---|
| Date | 2011-12-15 14:48 +0200 |
| Subject | Re: % is not an operator [was Re: Verbose and flexible args and kwargs syntax] |
| Message-ID | <qotaa6u2e7t.fsf@ruuvi.it.helsinki.fi> |
| In reply to | #17262 |
rusi writes:
> On Dec 15, 3:58 pm, Chris Angelico wrote:
> > On Thu, Dec 15, 2011 at 9:47 PM, Robert Kern wrote:
> > > 42 = 2 mod 5
> > > 2 = 42 mod 5
> >
> > It might make more sense to programmers if you think of it as
> > written:
> >
> > 42 = 2, mod 5
> > 2 = 42, mod 5
> >
> > ChrisA
>
> For the record I should say that the guy who taught me abstract
> algebra, said about as much:
> He said that the notation
> a == b mod n
> should be written as
> a ==n b
> (read the == as 3 horizontal lines and the n as a subscript)
I think the modulus is usually given in parentheses and preferably
some whitespace: in text, a == b (mod n), using == for the triple -,
and in a display:
a == b (mod n).
I think even a == b == c (mod n), without repeating the modulus every
time. (A subscript sounds good if the modulus is simple. Perhaps it
often is.)
That way it does not even look like a binary operator. I think Graham,
Knuth, and Patashnik play it nicely in their book Concrete
Mathematics, where they have both mods: the congruence relation, and
the binary operator. The book is targeted for computer scientists.
As if mathematicians didn't use the exact same notations for different
purposes, even in the same context, and often with no problems
whatsoever as long as all parties happen to know what they are talking
about. Often the uses are analogous, but at least the two main uses of
(x,y) differ wildly. (So Knuth uses (x .. y) for the interval, but he
is a programmer.)
[toc] | [prev] | [next] | [standalone]
| From | Terry Reedy <tjreedy@udel.edu> |
|---|---|
| Date | 2011-12-15 18:15 -0500 |
| Subject | Re: % is not an operator [was Re: Verbose and flexible args and kwargs syntax] |
| Message-ID | <mailman.3705.1323990921.27778.python-list@python.org> |
| In reply to | #17262 |
On 12/15/2011 6:04 AM, rusi wrote: > On Dec 15, 3:58 pm, Chris Angelico<ros...@gmail.com> wrote: >> On Thu, Dec 15, 2011 at 9:47 PM, Robert Kern<robert.k...@gmail.com> wrote: >>> 42 = 2 mod 5 >>> 2 = 42 mod 5 >> >> It might make more sense to programmers if you think of it as written: >> >> 42 = 2, mod 5 >> 2 = 42, mod 5 Better, using ascii text, would be 42 =mod5 2 where =mod is a parameterized equivalence relation that is coarser than = (which is =mod-infinity). divmod(a,inf) = 0,a. =mod1 is the most coarse relation in that it make every count equivalent. divmod(a,1) = a,1. > For the record I should say that the guy who taught me abstract > algebra, said about as much: > He said that the notation > a == b mod n > should be written as > a ==n b > (read the == as 3 horizontal lines and the n as a subscript) The 3 horizontal line symbol is often used for equivalence relations other than =. -- Terry Jan Reedy
[toc] | [prev] | [next] | [standalone]
| From | Paul Rudin <paul.nospam@rudin.co.uk> |
|---|---|
| Date | 2011-12-14 09:43 +0000 |
| Subject | Re: % is not an operator |
| Message-ID | <87r507qyif.fsf@no-fixed-abode.cable.virginmedia.net> |
| In reply to | #17178 |
Steven D'Aprano <steve+comp.lang.python@pearwood.info> writes: > The existence of two potential answers for the remainder is certainly > correct, but the conclusion that remainder is not a binary operation > doesn't follow. It is a binary relation. This depends on your definition of "operation". Normally an operation is a function, rather than just a relation.
[toc] | [prev] | [next] | [standalone]
| From | Nick Dokos <nicholas.dokos@hp.com> |
|---|---|
| Date | 2011-12-12 12:58 -0500 |
| Message-ID | <mailman.3562.1323713224.27778.python-list@python.org> |
| In reply to | #17064 |
Jussi Piitulainen <jpiitula@ling.helsinki.fi> wrote: > Terry Reedy writes: > > On 12/12/2011 5:59 AM, Jussi Piitulainen wrote: > > > > > Past experience in mathematics newsgroups tells me > > > that some mathematicians do not accept the existence of any remainder > > > operator at all. > > > > Even though they carry hour/minute/second remindering devices on their > > bodies and put year/month/day remaindering devices on their wall? > > 'Twould be strange indeed! > > They recognize modular arithmetic but for some reason insist that > there is no such _binary operation_. But as I said, I don't understand > their concern. (Except the related concern about some programming > languages, not Python, where the remainder does not behave well with > respect to division.) They are probably arguing that it's uniquely defined only on ZxN and that there are different conventions to extend it to ZxZ (the programming languages problem that you allude to above - although I don't know what you mean by "does not behave well wrt division"). See http://en.wikipedia.org/wiki/Remainder If you choose one convention and stick to it, it becomes a well-defined binary operation. C99 goes one way, python goes a different way (and mathematics textbooks generally go a third way) and they are all happy, as long as they don't try to talk to each other (e.g., porting C99 programs to python unthinkingly leads to trouble - duh). It was implementation dependent in old C (whatever the hardware would give you), which predictably - with 20-20 hindsight - turned out to be a Very Bad Idea. Nick PS Z = integers, N = non-negative integers
[toc] | [prev] | [next] | [standalone]
| From | Jussi Piitulainen <jpiitula@ling.helsinki.fi> |
|---|---|
| Date | 2011-12-14 11:04 +0200 |
| Message-ID | <qotehw7cynv.fsf@ruuvi.it.helsinki.fi> |
| In reply to | #17068 |
Nick Dokos writes: > Jussi Piitulainen wrote: > > They recognize modular arithmetic but for some reason insist that > > there is no such _binary operation_. But as I said, I don't > > understand their concern. (Except the related concern about some > > programming languages, not Python, where the remainder does not > > behave well with respect to division.) > > They are probably arguing that it's uniquely defined only on ZxN and > that there are different conventions to extend it to ZxZ (the > programming languages problem that you allude to above - although I > don't know what you mean by "does not behave well wrt division"). I think Boute [1] says Standard Pascal or some such language failed to have x div y + x rem y = x, but I can't check the reference now. That at least waes what I had in mind. Having x rem y but leaving it underspecified is another such problem: then it is unspecified whether the equation holds. [1] <http://en.wikipedia.org/wiki/Modulo_operation> > If you choose one convention and stick to it, it becomes a > well-defined binary operation. That's what I'd like to think.
[toc] | [prev] | [next] | [standalone]
| From | gene heskett <gheskett@wdtv.com> |
|---|---|
| Date | 2011-12-12 12:46 -0500 |
| Message-ID | <mailman.3561.1323711981.27778.python-list@python.org> |
| In reply to | #16993 |
On Monday, December 12, 2011 12:44:27 PM Chris Angelico did opine: > On Tue, Dec 13, 2011 at 2:55 AM, Nick Dokos <nicholas.dokos@hp.com> wrote: > > Terry Reedy <tjreedy@udel.edu> wrote: > >> calculations are helped by the fact that (a+b) % c == a%c + b%c, so > > > > As long as we understand that == here does not mean "equal", only > > "congruent modulo c", e.g try a = 13, b = 12, c = 7. > > This is the basis of the grade-school "casting out nines" method of > checking arithmetic. Set c=9 and you can calculate N%c fairly readily > (digit sum - I'm assuming here that the arithmetic is being done in > decimal); the sum of the remainders should equal the remainder of the > sum, but there's the inherent assumption that if the remainders sum to > something greater than nine, you digit-sum it to get the true > remainder. > > (Technically the sum of the digits of a base-10 number is not the same > as that number mod 9, but if you accept that 0 == 9, it works fine.) > > ChrisA And that is precisely the reason I have failed to understand why the 1-10 decimal system seems to have hung on for several hundred years when it is clearly broken. Cheers, Gene -- "There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order." -Ed Howdershelt (Author) My web page: <http://coyoteden.dyndns-free.com:85/gene> Grub first, then ethics. -- Bertolt Brecht
[toc] | [prev] | [next] | [standalone]
| From | Dave Angel <d@davea.name> |
|---|---|
| Date | 2011-12-12 13:04 -0500 |
| Message-ID | <mailman.3564.1323713392.27778.python-list@python.org> |
| In reply to | #16993 |
On 12/12/2011 12:46 PM, gene heskett wrote: > On Monday, December 12, 2011 12:44:27 PM Chris Angelico did opine: > <snip> >> This is the basis of the grade-school "casting out nines" method of >> checking arithmetic. Set c=9 and you can calculate N%c fairly readily >> (digit sum - I'm assuming here that the arithmetic is being done in >> decimal); the sum of the remainders should equal the remainder of the >> sum, but there's the inherent assumption that if the remainders sum to >> something greater than nine, you digit-sum it to get the true >> remainder. >> >> (Technically the sum of the digits of a base-10 number is not the same >> as that number mod 9, but if you accept that 0 == 9, it works fine.) >> >> ChrisA > And that is precisely the reason I have failed to understand why the 1-10 > decimal system seems to have hung on for several hundred years when it is > clearly broken. > I assume this was facetious, but in case not, I'd point out that any other number base will have similar modulo characteristics, except for base 2, where all numbers are congruent modulo 1, so it doesn't do much for checking values. For example, if you were using a number system of base 8, you could do "casting out sevens" by adding the digits together. -- DaveA
[toc] | [prev] | [next] | [standalone]
| From | Nick Dokos <nicholas.dokos@hp.com> |
|---|---|
| Date | 2011-12-12 13:02 -0500 |
| Message-ID | <mailman.3565.1323713477.27778.python-list@python.org> |
| In reply to | #16993 |
gene heskett <gheskett@wdtv.com> wrote: > On Monday, December 12, 2011 12:44:27 PM Chris Angelico did opine: > > > On Tue, Dec 13, 2011 at 2:55 AM, Nick Dokos <nicholas.dokos@hp.com> > wrote: > > > Terry Reedy <tjreedy@udel.edu> wrote: > > >> calculations are helped by the fact that (a+b) % c == a%c + b%c, so > > > > > > As long as we understand that == here does not mean "equal", only > > > "congruent modulo c", e.g try a = 13, b = 12, c = 7. > > > > This is the basis of the grade-school "casting out nines" method of > > checking arithmetic. Set c=9 and you can calculate N%c fairly readily > > (digit sum - I'm assuming here that the arithmetic is being done in > > decimal); the sum of the remainders should equal the remainder of the > > sum, but there's the inherent assumption that if the remainders sum to > > something greater than nine, you digit-sum it to get the true > > remainder. > > > > (Technically the sum of the digits of a base-10 number is not the same > > as that number mod 9, but if you accept that 0 == 9, it works fine.) > > > > ChrisA > > And that is precisely the reason I have failed to understand why the 1-10 It's not clear from the above what you mean by "that is presicely the reason": what is "that"? > decimal system seems to have hung on for several hundred years when it is > clearly broken. > "broken" how? Thanks, Nick
[toc] | [prev] | [standalone]
Page 5 of 5 — ← Prev page 1 2 3 4 [5]
Back to top | Article view | comp.lang.python
csiph-web