Re: What is structured programming (was for/while else doesn't make sense)

2016-06-17 Thread Lawrence D’Oliveiro
On Saturday, June 18, 2016 at 4:32:26 AM UTC+12, Rustom Mody wrote: > I wonder whether "red herring" is your red herring I wasn’t the one trying to draw a completely spurious equivalence between structured programming and gotos. -- https://mail.python.org/mailman/listinfo/python-list

Re: What is structured programming (was for/while else doesn't make sense)

2016-06-17 Thread Rustom Mody
On Friday, June 17, 2016 at 7:23:27 AM UTC+5:30, Lawrence D’Oliveiro wrote: > On Thursday, June 16, 2016 at 11:13:14 PM UTC+12, Rustom Mody wrote: > > > Please see https://en.wikipedia.org/wiki/Nassi%E2%80%93Shneiderman_diagram > > > > | Nassi–Shneiderman diagrams are (almost) isomorphic with > >

Re: What is structured programming (was for/while else doesn't make sense)

2016-06-16 Thread Lawrence D’Oliveiro
On Thursday, June 16, 2016 at 11:13:14 PM UTC+12, Rustom Mody wrote: > Please see https://en.wikipedia.org/wiki/Nassi%E2%80%93Shneiderman_diagram > > | Nassi–Shneiderman diagrams are (almost) isomorphic with > | flowcharts. Everything you can represent with a Nassi–Shneiderman > | diagram you can

Re: What is structured programming (was for/while else doesn't make sense)

2016-06-16 Thread Rustom Mody
On Thursday, June 16, 2016 at 11:27:15 AM UTC+5:30, Lawrence D’Oliveiro wrote: > On Thursday, June 16, 2016 at 5:48:48 PM UTC+12, Rustom Mody wrote: > > On Thursday, June 16, 2016 at 8:25:10 AM UTC+5:30, Lawrence D’Oliveiro > > wrote: > > So here is the formal definition I remember from decades ag

Re: What is structured programming (was for/while else doesn't make sense)

2016-06-16 Thread Lawrence D’Oliveiro
On Thursday, June 16, 2016 at 5:48:48 PM UTC+12, Rustom Mody wrote: > On Thursday, June 16, 2016 at 8:25:10 AM UTC+5:30, Lawrence D’Oliveiro wrote: > So here is the formal definition I remember from decades ago: > > A structured flow-graph is one that has a single point of entry and exit. > And is

What is structured programming (was for/while else doesn't make sense)

2016-06-15 Thread Rustom Mody
On Thursday, June 16, 2016 at 8:25:10 AM UTC+5:30, Lawrence D’Oliveiro wrote: > On Thursday, June 16, 2016 at 1:51:54 AM UTC+12, Random832 wrote: > > ... and in particular it does not establish that break is in any way > > less structured than any other constructs that have keywords. > > Interesti

Re: for / while else doesn't make sense

2016-06-15 Thread Lawrence D’Oliveiro
On Thursday, June 16, 2016 at 1:51:54 AM UTC+12, Random832 wrote: > ... and in particular it does not establish that break is in any way > less structured than any other constructs that have keywords. Interesting that those who objected to my use of while-True-break loops could not come up with a

Re: for / while else doesn't make sense

2016-06-15 Thread Lawrence D’Oliveiro
On Thursday, June 16, 2016 at 2:32:00 AM UTC+12, Rustom Mody wrote: > Here is C.A.R Hoare's Turing award speech: > https://www.cs.fsu.edu/~engelen/courses/COP4610/hoare.pdf > > in which (2nd last page) he claims that Ada is a threat to civilization... > because it has something as terrible as exc

Re: for / while else doesn't make sense

2016-06-15 Thread Steven D'Aprano
On Thu, 16 Jun 2016 03:03 am, Rustom Mody wrote: > So break also has its uses. Lets just not pretend its structured What's your definition of "structured" that makes "break" unstructured? Suppose I have a language, L, with a keyword "fnord". How do I tell whether the fnord feature makes the lan

Re: for / while else doesn't make sense

2016-06-15 Thread Steven D'Aprano
On Wed, 15 Jun 2016 09:19 pm, Rustom Mody wrote: > On Wednesday, June 15, 2016 at 8:42:33 AM UTC+5:30, Steven D'Aprano wrote: >> On Wed, 15 Jun 2016 01:33 am, Rustom Mody wrote: [...] >> > And break is a euphemism for goto >> >> Sort of. A break is a jump, and a goto is a jump, but apart from tha

Re: for / while else doesn't make sense

2016-06-15 Thread Random832
On Wed, Jun 15, 2016, at 13:18, Michael Selik wrote: > On Wed, Jun 15, 2016, 10:28 AM Rustom Mody wrote: > > > Where did the question of "break can be written as goto" come from? > > > > Stephen said the "else" in for-else was "unconditional". He argued that > neither the presence nor absence of

Re: for / while else doesn't make sense

2016-06-15 Thread BartC
On 15/06/2016 18:03, Rustom Mody wrote: OTOH Duff's device shows terrifyingly unstructured code with nary a goto/break in sight I agree, and these mostly originate in C. It's full of crude features that should have been pensioned off decades ago, but amazingly it is still around and highly i

Re: for / while else doesn't make sense

2016-06-15 Thread Michael Selik
On Wed, Jun 15, 2016, 10:28 AM Rustom Mody wrote: > Where did the question of "break can be written as goto" come from? > Stephen said the "else" in for-else was "unconditional". He argued that neither the presence nor absence of a break should be considered a condition, because we don't conside

Re: for / while else doesn't make sense

2016-06-15 Thread Rustom Mody
On Wednesday, June 15, 2016 at 9:24:21 PM UTC+5:30, Random832 wrote: > On Wed, Jun 15, 2016, at 10:20, Rustom Mody wrote: > > Claim is that the damaging propensities of goto are replicable with > > break. > > The "damaging propensity" in this particular case simply comes from the > fact that it's

Re: for / while else doesn't make sense

2016-06-15 Thread Random832
On Wed, Jun 15, 2016, at 10:20, Rustom Mody wrote: > Claim is that the damaging propensities of goto are replicable with > break. The "damaging propensity" in this particular case simply comes from the fact that it's a statement that can appear in the body of an if statement (the real flaw that ca

Re: for / while else doesn't make sense

2016-06-15 Thread Rustom Mody
On Wednesday, June 15, 2016 at 7:21:54 PM UTC+5:30, Random832 wrote: > On Wed, Jun 15, 2016, at 07:19, Rustom Mody wrote: > > I thought there'd be many examples for showing that break is just goto in > > disguise... Evidently not > > > > So here is an example in more detail for why/how break=goto

Re: for / while else doesn't make sense

2016-06-15 Thread Rustom Mody
On Wednesday, June 15, 2016 at 7:21:54 PM UTC+5:30, Random832 wrote: > On Wed, Jun 15, 2016, at 07:19, Rustom Mody wrote: > > I thought there'd be many examples for showing that break is just goto in > > disguise... Evidently not > > > > So here is an example in more detail for why/how break=goto

Re: for / while else doesn't make sense

2016-06-15 Thread Chris Angelico
On Wed, Jun 15, 2016 at 11:51 PM, Random832 wrote: > if(x) true_body; else false_body; > > is syntactic sugar for: > > if(!x) goto else; > true_body; > goto end; > else: false_body; > end: ; And I remember writing GW-BASIC code like this, because we didn't have block if. You could put a single st

Re: for / while else doesn't make sense

2016-06-15 Thread Random832
On Wed, Jun 15, 2016, at 07:19, Rustom Mody wrote: > I thought there'd be many examples for showing that break is just goto in > disguise... Evidently not > > So here is an example in more detail for why/how break=goto: > > http://blog.languager.org/2016/06/break-is-goto-in-disguise.html So? S

Re: for / while else doesn't make sense

2016-06-15 Thread Rustom Mody
On Wednesday, June 15, 2016 at 5:57:51 PM UTC+5:30, BartC wrote: > On 15/06/2016 12:19, Rustom Mody wrote: > > On Wednesday, June 15, 2016 at 8:42:33 AM UTC+5:30, Steven D'Aprano wrote: > > >> Sort of. A break is a jump, and a goto is a jump, but apart from that, > >> they're not really the same t

Re: for / while else doesn't make sense

2016-06-15 Thread BartC
On 15/06/2016 12:19, Rustom Mody wrote: On Wednesday, June 15, 2016 at 8:42:33 AM UTC+5:30, Steven D'Aprano wrote: Sort of. A break is a jump, and a goto is a jump, but apart from that, they're not really the same thing. A goto can jump (almost) anywhere. Depending on the language, they can ju

Re: for / while else doesn't make sense

2016-06-15 Thread Rustom Mody
On Wednesday, June 15, 2016 at 8:42:33 AM UTC+5:30, Steven D'Aprano wrote: > On Wed, 15 Jun 2016 01:33 am, Rustom Mody wrote: > > > On Tuesday, June 14, 2016 at 8:13:53 AM UTC+5:30, Steven D'Aprano wrote: > >> No. The sun exploding was me gently mocking you for your comment > >> disputing the "unc

Re: for / while else doesn't make sense

2016-06-14 Thread Rustom Mody
On Wednesday, June 15, 2016 at 8:42:33 AM UTC+5:30, Steven D'Aprano wrote: > On Wed, 15 Jun 2016 01:33 am, Rustom Mody wrote: > > > On Tuesday, June 14, 2016 at 8:13:53 AM UTC+5:30, Steven D'Aprano wrote: > >> No. The sun exploding was me gently mocking you for your comment > >> disputing the "unc

Re: for / while else doesn't make sense

2016-06-14 Thread Steven D'Aprano
On Wed, 15 Jun 2016 01:33 am, Rustom Mody wrote: > On Tuesday, June 14, 2016 at 8:13:53 AM UTC+5:30, Steven D'Aprano wrote: >> No. The sun exploding was me gently mocking you for your comment >> disputing the "unconditional" part. Yes, you are technically right that >> technically the "else" block

Re: for / while else doesn't make sense

2016-06-14 Thread Rustom Mody
On Wednesday, June 15, 2016 at 4:58:05 AM UTC+5:30, Lawrence D’Oliveiro wrote: > On Wednesday, June 15, 2016 at 3:34:14 AM UTC+12, Rustom Mody wrote: > > > And break is a euphemism for goto > > Is this the old > “structured-programming-is-mathematically-equivalent-to-gotos” red herring > again?

Re: for / while else doesn't make sense

2016-06-14 Thread Rustom Mody
On Tuesday, June 14, 2016 at 8:13:53 AM UTC+5:30, Steven D'Aprano wrote: > No. The sun exploding was me gently mocking you for your comment disputing > the "unconditional" part. Yes, you are technically right that technically > the "else" block will only run if no "break" is reached, and no "return

Re: for / while else doesn't make sense

2016-06-14 Thread Chris Angelico
On Tue, Jun 14, 2016 at 11:51 PM, Ian Kelly wrote: > On Tue, Jun 14, 2016 at 5:39 AM, alister wrote: >> On Tue, 14 Jun 2016 12:43:35 +1000, Steven D'Aprano wrote: >>> >>> On this list, I daresay somebody will insist that if their computer is >>> on one of Jupiter's moons it will keep running fine

Re: for / while else doesn't make sense

2016-06-14 Thread Ian Kelly
On Tue, Jun 14, 2016 at 5:39 AM, alister wrote: > On Tue, 14 Jun 2016 12:43:35 +1000, Steven D'Aprano wrote: >> >> On this list, I daresay somebody will insist that if their computer is >> on one of Jupiter's moons it will keep running fine and therefore I'm >> wrong. >> > > Anyone on a moon of Ju

Re: for / while else doesn't make sense

2016-06-14 Thread alister
On Tue, 14 Jun 2016 12:43:35 +1000, Steven D'Aprano wrote: > > On this list, I daresay somebody will insist that if their computer is > on one of Jupiter's moons it will keep running fine and therefore I'm > wrong. > Anyone on a moon of Jupiter would not be able to get internet access (TCP/IP ti

Re: for / while else doesn't make sense

2016-06-13 Thread Michael Selik
On Mon, Jun 13, 2016 at 10:46 PM Steven D'Aprano wrote: > On Tue, 14 Jun 2016 09:45 am, Michael Selik wrote: > > On Sun, Jun 12, 2016 at 10:16 PM Steven D'Aprano > > wrote: > >> On Mon, 13 Jun 2016 04:44 am, Michael Selik wrote: > >> > On Sun, Jun 12, 2016 at 6:11 AM Steven D'Aprano < > >> > ste

Re: for / while else doesn't make sense

2016-06-13 Thread Steven D'Aprano
On Tue, 14 Jun 2016 09:45 am, Michael Selik wrote: > On Sun, Jun 12, 2016 at 10:16 PM Steven D'Aprano > wrote: > >> On Mon, 13 Jun 2016 04:44 am, Michael Selik wrote: >> >> > On Sun, Jun 12, 2016 at 6:11 AM Steven D'Aprano < >> > steve+comp.lang.pyt...@pearwood.info> wrote: >> > >> >> - run the

Re: for / while else doesn't make sense

2016-06-13 Thread Michael Selik
On Sun, Jun 12, 2016 at 10:16 PM Steven D'Aprano wrote: > On Mon, 13 Jun 2016 04:44 am, Michael Selik wrote: > > > On Sun, Jun 12, 2016 at 6:11 AM Steven D'Aprano < > > steve+comp.lang.pyt...@pearwood.info> wrote: > > > >> - run the for block > >> - THEN unconditionally run the "else" block > >>

Re: for / while else doesn't make sense

2016-06-12 Thread Rustom Mody
On Monday, June 13, 2016 at 7:42:25 AM UTC+5:30, Steven D'Aprano wrote: > On Mon, 13 Jun 2016 04:44 am, Michael Selik wrote: > > > On Sun, Jun 12, 2016 at 6:11 AM Steven D'Aprano wrote: > > > >> - run the for block > >> - THEN unconditionally run the "else" block > >> > > > > Saying "unconditio

Re: for / while else doesn't make sense

2016-06-12 Thread Steven D'Aprano
On Mon, 13 Jun 2016 04:44 am, Michael Selik wrote: > On Sun, Jun 12, 2016 at 6:11 AM Steven D'Aprano < > steve+comp.lang.pyt...@pearwood.info> wrote: > >> - run the for block >> - THEN unconditionally run the "else" block >> > > Saying "unconditionally" is a bit misleading here. As you say, it's

Re: for / while else doesn't make sense

2016-06-12 Thread Michael Selik
On Sun, Jun 12, 2016 at 6:11 AM Steven D'Aprano < steve+comp.lang.pyt...@pearwood.info> wrote: > - run the for block > - THEN unconditionally run the "else" block > Saying "unconditionally" is a bit misleading here. As you say, it's conditioned on completing the loop without break/return/raise. -

Re: for / while else doesn't make sense

2016-06-12 Thread Steven D'Aprano
On Sunday 12 June 2016 17:01, pavlovevide...@gmail.com wrote: > On Thursday, May 19, 2016 at 9:43:56 AM UTC-7, Herkermer Sherwood wrote: >> Most keywords in Python make linguistic sense, but using "else" in for and >> while structures is kludgy and misleading. I am under the assumption that >> thi

Re: for / while else doesn't make sense

2016-06-12 Thread pavlovevidence
On Thursday, May 19, 2016 at 9:43:56 AM UTC-7, Herkermer Sherwood wrote: > Most keywords in Python make linguistic sense, but using "else" in for and > while structures is kludgy and misleading. I am under the assumption that > this was just utilizing an already existing keyword. Adding another lik

Re: for / while else doesn't make sense

2016-06-10 Thread Gregory Ewing
Steven D'Aprano wrote: I have a 2000 inch monitor, and by using a narrow proportional font set to 5pt, I can display the entire Python standard library including tests on screen at once. Then it's just a matter of using my trusty 4" reflecting telescope to zoom in on any part of the screen I like

Re: for / while else doesn't make sense

2016-06-10 Thread Marko Rauhamaa
Ian Kelly : > On Jun 10, 2016 6:37 AM, "Marko Rauhamaa" wrote: >> If your display can show 1,500 lines at once, that's your limit. Mine >> shows 70. > > I disagree on that point. For a typical-size display, it's a > reasonable guideline. The point I'm making is that if I'm accusing you for writi

Re: for / while else doesn't make sense

2016-06-10 Thread Steven D'Aprano
On Sat, 11 Jun 2016 12:00 am, Ian Kelly wrote: > On Jun 10, 2016 6:37 AM, "Marko Rauhamaa" wrote: >> If your display can show 1,500 lines at once, that's your limit. Mine >> shows 70. > > I disagree on that point. For a typical-size display, it's a reasonable > guideline. But just because your

Re: for / while else doesn't make sense

2016-06-10 Thread Ian Kelly
On Jun 10, 2016 6:37 AM, "Marko Rauhamaa" wrote: > > alister : > > > Or more simply a hard fixed RULE (MUST be less than X lines) is Bad. > > It's not X lines, it's "you must see the whole function at once." > > If your display can show 1,500 lines at once, that's your limit. Mine > shows 70. I d

Re: for / while else doesn't make sense

2016-06-10 Thread alister
On Fri, 10 Jun 2016 15:31:11 +0300, Marko Rauhamaa wrote: > alister : > >> Or more simply a hard fixed RULE (MUST be less than X lines) is Bad. > > It's not X lines, it's "you must see the whole function at once." > > If your display can show 1,500 lines at once, that's your limit. Mine > shows

Re: for / while else doesn't make sense

2016-06-10 Thread Marko Rauhamaa
alister : > Or more simply a hard fixed RULE (MUST be less than X lines) is Bad. It's not X lines, it's "you must see the whole function at once." If your display can show 1,500 lines at once, that's your limit. Mine shows 70. > a flexible GUIDELINE on the other hand is reasonable. There are r

Re: for / while else doesn't make sense

2016-06-10 Thread alister
On Thu, 09 Jun 2016 18:19:23 +1000, Steven D'Aprano wrote: > On Thursday 09 June 2016 10:34, Lawrence D’Oliveiro wrote: > >> In my undergraduate Comp Sci classes, we used to discuss arbitrary >> rules like limiting functions to n lines. With real-world experience, >> it soon became clear that suc

Re: for / while else doesn't make sense

2016-06-09 Thread Grady Martin
On 2016年05月19日 11時02分, Ian Kelly wrote: "else" makes sense from a certain point of view, but I think that logic may not be communicated well. At the start of each loop iteration, the loop construct makes a test for whether the loop should continue or not. If that test ever fails (i.e. if the cond

Re: for / while else doesn't make sense

2016-06-09 Thread Steven D'Aprano
On Thursday 09 June 2016 10:34, Lawrence D’Oliveiro wrote: > In my undergraduate Comp Sci classes, we used to discuss arbitrary rules like > limiting functions to n lines. With real-world experience, it soon became > clear that such rules were a waste of time. A function should be just as big > as

Re: for / while else doesn't make sense

2016-06-08 Thread Lawrence D’Oliveiro
On Wednesday, June 8, 2016 at 5:27:41 PM UTC+12, Marko Rauhamaa wrote: > Someone mentioned you had a 500-line function. In my undergraduate Comp Sci classes, we used to discuss arbitrary rules like limiting functions to n lines. With real-world experience, it soon became clear that such rules w

Re: for / while else doesn't make sense

2016-06-07 Thread Marko Rauhamaa
Lawrence D’Oliveiro : > On Wednesday, June 8, 2016 at 10:07:05 AM UTC+12, Marko Rauhamaa wrote: >> Lawrence D’Oliveiro: > >>> While elsewhere, you were criticizing my code for already being so >>> terribly large... >> >> Code can be large, only no function should be longer than ~70 lines >> or wi

Re: for / while else doesn't make sense

2016-06-07 Thread Marko Rauhamaa
Lawrence D’Oliveiro : > On Tuesday, June 7, 2016 at 8:00:31 PM UTC+12, Marko Rauhamaa wrote: >> I, too, insist that every function/method must be visible at once in the >> editor window. > > From subprocess.py in the Python 3.5 distribution: > [...] > Is that “visible at once” in your editor windo

Re: for / while else doesn't make sense

2016-06-07 Thread Ethan Furman
On 06/01/2016 04:39 PM, Lawrence D’Oliveiro wrote: [multiple apparent trolls redacted] This thread is dead. Please stop beating it. -- ~Ethan~ -- https://mail.python.org/mailman/listinfo/python-list

Re: for / while else doesn't make sense

2016-06-07 Thread Ned Batchelder
On Tuesday, June 7, 2016 at 9:29:59 PM UTC-4, Lawrence D’Oliveiro wrote: > On Wednesday, June 8, 2016 at 12:32:01 PM UTC+12, Ned Batchelder wrote: > > > Lawrence writes code in an unusual style... > > “Unusual” I can deal with. But when some people react with outrage, then it > becomes clear the

Re: for / while else doesn't make sense

2016-06-07 Thread Lawrence D’Oliveiro
On Wednesday, June 8, 2016 at 12:32:01 PM UTC+12, Ned Batchelder wrote: > On Tuesday, June 7, 2016 at 6:07:23 PM UTC-4, Lawrence D’Oliveiro wrote: > > On Tuesday, June 7, 2016 at 8:00:31 PM UTC+12, Marko Rauhamaa wrote: > > > I understand you are hurt when your code is criticized bluntly. However,

Re: for / while else doesn't make sense

2016-06-07 Thread Lawrence D’Oliveiro
On Wednesday, June 8, 2016 at 12:32:01 PM UTC+12, Ned Batchelder wrote: > Lawrence writes code in an unusual style... “Unusual” I can deal with. But when some people react with outrage, then it becomes clear they view my code as a personal attack. -- https://mail.python.org/mailman/listinfo/pyt

Re: for / while else doesn't make sense

2016-06-07 Thread Ned Batchelder
On Tuesday, June 7, 2016 at 6:07:23 PM UTC-4, Lawrence D’Oliveiro wrote: > On Tuesday, June 7, 2016 at 8:00:31 PM UTC+12, Marko Rauhamaa wrote: > > I understand you are hurt when your code is criticized bluntly. However, > > you *did* stick your head out. > > Don’t worry, I am not the thin-skinned

Re: for / while else doesn't make sense

2016-06-07 Thread Ian Kelly
On Tue, Jun 7, 2016 at 3:58 PM, Lawrence D’Oliveiro wrote: > On Tuesday, June 7, 2016 at 11:53:46 PM UTC+12, Ian wrote: >> On Tue, Jun 7, 2016 at 1:52 AM, Lawrence D’Oliveiro wrote: > >>> Wow, that’s only twice the length of the code you’re replacing. Well done. >> >> Huh? The example that you pos

Re: for / while else doesn't make sense

2016-06-07 Thread Lawrence D’Oliveiro
On Wednesday, June 8, 2016 at 10:07:05 AM UTC+12, Marko Rauhamaa wrote: > Lawrence D’Oliveiro: >> While elsewhere, you were criticizing my code for already being so >> terribly large... > > Code can be large, only no function should be longer than ~70 lines or > wider than 79 columns. If your fun

Re: for / while else doesn't make sense

2016-06-07 Thread Lawrence D’Oliveiro
On Tuesday, June 7, 2016 at 8:00:31 PM UTC+12, Marko Rauhamaa wrote: > I understand you are hurt when your code is criticized bluntly. However, > you *did* stick your head out. Don’t worry, I am not the thin-skinned type. > I, too, insist that every function/method must be visible at once in the

Re: for / while else doesn't make sense

2016-06-07 Thread Marko Rauhamaa
Lawrence D’Oliveiro : > While elsewhere, you were criticizing my code for already being so > terribly large... Code can be large, only no function should be longer than ~70 lines or wider than 79 columns. If your function grows above that limit, you should refactor it and break it into multiple su

Re: for / while else doesn't make sense

2016-06-07 Thread Lawrence D’Oliveiro
On Tuesday, June 7, 2016 at 11:53:46 PM UTC+12, Ian wrote: > On Tue, Jun 7, 2016 at 1:52 AM, Lawrence D’Oliveiro wrote: >> Wow, that’s only twice the length of the code you’re replacing. Well done. > > Huh? The example that you posted was 17 lines, excluding comments. My > replacement code is 17

Re: for / while else doesn't make sense

2016-06-07 Thread Lawrence D’Oliveiro
On Wednesday, June 8, 2016 at 12:28:02 AM UTC+12, Dan Sommers wrote: > I notice plenty of break statements scattered throughout your loop > bodies. Mixing the loop's exit conditions in with the logic is equally > unstructured. Is this the old “structured-programming-is-mathematically-equivalent-t

Re: for / while else doesn't make sense

2016-06-07 Thread Dan Sommers
On Tue, 07 Jun 2016 00:53:31 -0700, Lawrence D’Oliveiro wrote: > On Tuesday, June 7, 2016 at 3:34:39 PM UTC+12, Dan Sommers wrote: > >> I used to write a lot of assembly code, for a lot of different CPUs, and >> they all had a common, versatile looping form which could be arranged in >> different

Re: for / while else doesn't make sense

2016-06-07 Thread Ian Kelly
On Tue, Jun 7, 2016 at 1:52 AM, Lawrence D’Oliveiro wrote: > Wow, that’s only twice the length of the code you’re replacing. Well done. Huh? The example that you posted was 17 lines, excluding comments. My replacement code is 17 lines, excluding comments. Where are you getting "twice the length"

Re: for / while else doesn't make sense

2016-06-07 Thread Steven D'Aprano
On Tuesday 07 June 2016 17:52, Lawrence D’Oliveiro wrote: > On Tuesday, June 7, 2016 at 4:36:37 PM UTC+12, Ian wrote: >> A 500-line function? Yikes, what an eyesore. When you have to include >> #end comments in order to visually match things up, that should be a >> smell that your code is excessiv

Re: for / while else doesn't make sense

2016-06-07 Thread Marko Rauhamaa
Lawrence D’Oliveiro : > On Tuesday, June 7, 2016 at 4:36:37 PM UTC+12, Ian wrote: >> A 500-line function? Yikes, what an eyesore. When you have to include >> #end comments in order to visually match things up, that should be a >> smell that your code is excessively complex. > > [...] > > Wow, that

Re: for / while else doesn't make sense

2016-06-07 Thread Lawrence D’Oliveiro
On Tuesday, June 7, 2016 at 3:34:39 PM UTC+12, Dan Sommers wrote: > I used to write a lot of assembly code, for a lot of different CPUs, and > they all had a common, versatile looping form which could be arranged in > different ways to suit the problem at hand. On most chips, it was (and > still

Re: for / while else doesn't make sense

2016-06-07 Thread Lawrence D’Oliveiro
On Tuesday, June 7, 2016 at 4:36:37 PM UTC+12, Ian wrote: > A 500-line function? Yikes, what an eyesore. When you have to include > #end comments in order to visually match things up, that should be a > smell that your code is excessively complex. Feel free to come up with a simpler version. >

Re: for / while else doesn't make sense

2016-06-06 Thread Ian Kelly
On Mon, Jun 6, 2016 at 6:51 PM, Lawrence D’Oliveiro wrote: > On Sunday, June 5, 2016 at 11:43:20 PM UTC+12, Marko Rauhamaa wrote: >> I often experiment with different loop constructs to find the one most >> pleasing to the eye. Working directly off iterators is quite rare but a >> while-vs-for con

Re: for / while else doesn't make sense

2016-06-06 Thread Dan Sommers
On Mon, 06 Jun 2016 17:51:24 -0700, Lawrence D’Oliveiro wrote: > It is nice to have a common, versatile looping form which can be > arranged in different ways to suit the problem at hand. That’s why I > like the C-style for-statement. [example snipped] I used to write a lot of assembly code, for

Re: for / while else doesn't make sense

2016-06-06 Thread Lawrence D’Oliveiro
On Sunday, June 5, 2016 at 11:43:20 PM UTC+12, Marko Rauhamaa wrote: > Then, you might overdo constructs like lambdas and maps. Who says you can have too many lambdas? -- https://mail.python.org/mailman/listinfo/python

Re: for / while else doesn't make sense

2016-06-06 Thread Lawrence D’Oliveiro
On Sunday, June 5, 2016 at 11:43:20 PM UTC+12, Marko Rauhamaa wrote: > I often experiment with different loop constructs to find the one most > pleasing to the eye. Working directly off iterators is quite rare but a > while-vs-for consideration is frequent. Also, should the stepping part > be in th

Re: for / while else doesn't make sense

2016-06-05 Thread Marko Rauhamaa
Ned Batchelder : > On Saturday, June 4, 2016 at 11:29:30 PM UTC-4, Lawrence D’Oliveiro wrote: >> > > item_iter = iter(items) >> > > while True : >> > > item = next(item_iter, None) >> > > if item == None : >> > > break >> > > if is_what_i_want(item) : >>

Re: for / while else doesn't make sense

2016-06-05 Thread Ned Batchelder
On Saturday, June 4, 2016 at 11:29:30 PM UTC-4, Lawrence D’Oliveiro wrote: > On Saturday, June 4, 2016 at 11:37:18 PM UTC+12, Ned Batchelder wrote: > > On Friday, June 3, 2016 at 11:43:33 PM UTC-4, Lawrence D’Oliveiro wrote: > > > On Saturday, June 4, 2016 at 3:00:36 PM UTC+12, Steven D'Aprano wrot

Re: for / while else doesn't make sense

2016-06-04 Thread Steven D'Aprano
On Sun, 5 Jun 2016 01:29 pm, Lawrence D’Oliveiro wrote: > On Saturday, June 4, 2016 at 11:37:18 PM UTC+12, Ned Batchelder wrote: >> On Friday, June 3, 2016 at 11:43:33 PM UTC-4, Lawrence D’Oliveiro wrote: >> > On Saturday, June 4, 2016 at 3:00:36 PM UTC+12, Steven D'Aprano wrote: >> > > You can ex

Re: for / while else doesn't make sense

2016-06-04 Thread Lawrence D’Oliveiro
On Saturday, June 4, 2016 at 11:37:18 PM UTC+12, Ned Batchelder wrote: > On Friday, June 3, 2016 at 11:43:33 PM UTC-4, Lawrence D’Oliveiro wrote: > > On Saturday, June 4, 2016 at 3:00:36 PM UTC+12, Steven D'Aprano wrote: > > > You can exit a loop because you have run out of items to process, or you

Re: for / while else doesn't make sense

2016-06-04 Thread Lawrence D’Oliveiro
On Saturday, June 4, 2016 at 9:27:58 PM UTC+12, Steven D'Aprano wrote: > Are you really questioning the need for for-loops to stop iterating > when they reach the end of the sequence or iterator? I just want to point out how you turn a discussion about the behaviour of loops into one about the be

Re: for / while else doesn't make sense

2016-06-04 Thread BartC
On 03/06/2016 17:22, Lawrence D’Oliveiro wrote: On Friday, June 3, 2016 at 9:33:32 PM UTC+12, BartC wrote: On 03/06/2016 03:47, Lawrence D’Oliveiro wrote: On Friday, June 3, 2016 at 8:52:52 AM UTC+12, BartC wrote: Simple iterative for-loops are more of a DIY effort... There is one case that

Re: for / while else doesn't make sense

2016-06-04 Thread Ned Batchelder
On Friday, June 3, 2016 at 11:43:33 PM UTC-4, Lawrence D’Oliveiro wrote: > On Saturday, June 4, 2016 at 3:00:36 PM UTC+12, Steven D'Aprano wrote: > > You can exit a loop because you have run out of items to process, or you can > > exit the loop because a certain condition has been met. > > But why

Re: for / while else doesn't make sense

2016-06-04 Thread Steven D'Aprano
On Sat, 4 Jun 2016 01:41 pm, Lawrence D’Oliveiro wrote: > On Saturday, June 4, 2016 at 2:22:18 PM UTC+12, Steven D'Aprano wrote: >> and a loop with two or more exits a *trivially different* way: >> >> for x in seq: >> do_something() >> if condition: >> break >> if another_cond

Re: for / while else doesn't make sense

2016-06-03 Thread Lawrence D’Oliveiro
On Saturday, June 4, 2016 at 3:00:36 PM UTC+12, Steven D'Aprano wrote: > You can exit a loop because you have run out of items to process, or you can > exit the loop because a certain condition has been met. But why should they be expressed differently? item_iter = iter(items) while True

Re: for / while else doesn't make sense

2016-06-03 Thread Lawrence D’Oliveiro
On Saturday, June 4, 2016 at 2:22:18 PM UTC+12, Steven D'Aprano wrote: > and a loop with two or more exits a *trivially different* way: > > for x in seq: > do_something() > if condition: > break > if another_condition: > break But that loop has 3 exits, written in two

Re: for / while else doesn't make sense

2016-06-03 Thread Steven D'Aprano
On Sat, 4 Jun 2016 02:24 am, Lawrence D’Oliveiro wrote: > On Saturday, June 4, 2016 at 3:52:42 AM UTC+12, Rob Gaddi wrote: >> Lawrence D’Oliveiro wrote: >> >>> The reason why I don’t like this is that there are two ways out of the >>> Python for-statement, and they are written quite differently.

Re: for / while else doesn't make sense

2016-06-03 Thread Steven D'Aprano
On Sat, 4 Jun 2016 02:22 am, Lawrence D’Oliveiro wrote: > In Python you write a loop with one exit in one way, a loop with two exits > in a different way, and a loop with more than two exits in yet another > entirely different way. Can you say “cognitive burden”? Yes I can, but I don't see the po

Re: for / while else doesn't make sense

2016-06-03 Thread Lawrence D’Oliveiro
On Saturday, June 4, 2016 at 3:52:42 AM UTC+12, Rob Gaddi wrote: > Lawrence D’Oliveiro wrote: > >> The reason why I don’t like this is that there are two ways out of the >> Python for-statement, and they are written quite differently. Why the >> asymmetry? Logically, all ways out of a loop are of

Re: for / while else doesn't make sense

2016-06-03 Thread Lawrence D’Oliveiro
On Friday, June 3, 2016 at 9:33:32 PM UTC+12, BartC wrote: > On 03/06/2016 03:47, Lawrence D’Oliveiro wrote: >> On Friday, June 3, 2016 at 8:52:52 AM UTC+12, BartC wrote: >>> Simple iterative for-loops are more of a DIY effort... >> >> There is one case that Python handles more nicely than C. > >

Re: for / while else doesn't make sense

2016-06-03 Thread Rob Gaddi
Lawrence D’Oliveiro wrote: > On Friday, June 3, 2016 at 8:09:21 AM UTC+12, Rob Gaddi wrote: >> Although your loop is really the _canonical_ use case for >> >> for loopvar in range(initial_value, limit+1): >> processing >> if found_what_im_looking_for: >> break >> else: >> do_w

Re: for / while else doesn't make sense

2016-06-03 Thread BartC
On 03/06/2016 03:47, Lawrence D’Oliveiro wrote: On Friday, June 3, 2016 at 8:52:52 AM UTC+12, BartC wrote: Simple iterative for-loops are more of a DIY effort... There is one case that Python handles more nicely than C. And that is iterating over a fixed set of values. E.g. in Python for

Re: for / while else doesn't make sense

2016-06-03 Thread BartC
On 03/06/2016 02:05, Lawrence D’Oliveiro wrote: On Friday, June 3, 2016 at 8:52:52 AM UTC+12, BartC wrote: One major objection was that C's 'for' isn't really a for-statement at all (as it is understood in most other languages that haven't just copied C's version), but is closer to a 'while' sta

Re: for / while else doesn't make sense

2016-06-02 Thread Lawrence D’Oliveiro
On Friday, June 3, 2016 at 8:52:52 AM UTC+12, BartC wrote: > Simple iterative for-loops are more of a DIY effort... There is one case that Python handles more nicely than C. And that is iterating over a fixed set of values. E.g. in Python for rendering in (False, True) : ... #end

Re: for / while else doesn't make sense

2016-06-02 Thread Lawrence D’Oliveiro
On Friday, June 3, 2016 at 8:52:52 AM UTC+12, BartC wrote: > One major objection was that C's 'for' isn't really a for-statement at > all (as it is understood in most other languages that haven't just > copied C's version), but is closer to a 'while' statement. Apart from having local loop varia

Re: for / while else doesn't make sense

2016-06-02 Thread Lawrence D’Oliveiro
On Friday, June 3, 2016 at 8:09:21 AM UTC+12, Rob Gaddi wrote: > Although your loop is really the _canonical_ use case for > > for loopvar in range(initial_value, limit+1): > processing > if found_what_im_looking_for: > break > else: > do_whatever_it_is_you_do_when_its_not_foun

Re: for / while else doesn't make sense

2016-06-02 Thread BartC
On 02/06/2016 21:09, Rob Gaddi wrote: Lawrence D’Oliveiro wrote: On Friday, May 20, 2016 at 4:43:56 AM UTC+12, Herkermer Sherwood wrote: Most keywords in Python make linguistic sense, but using "else" in for and while structures is kludgy and misleading. My objection is not to the choice of

Re: for / while else doesn't make sense

2016-06-02 Thread Ian Kelly
On Thu, Jun 2, 2016 at 2:09 PM, Rob Gaddi wrote: > The limited variable scoping is the only thing missing, and you can get > around that by telling yourself you're not going to use that variable > again, and then believing you on the matter. Or you can actually limit the variable scope using a fu

Re: for / while else doesn't make sense

2016-06-02 Thread Rob Gaddi
Lawrence D’Oliveiro wrote: > On Friday, May 20, 2016 at 4:43:56 AM UTC+12, Herkermer Sherwood wrote: >> Most keywords in Python make linguistic sense, but using "else" in for and >> while structures is kludgy and misleading. > > My objection is not to the choice of keyword, it’s to the whole desig

Re: for / while else doesn't make sense

2016-06-01 Thread Steven D'Aprano
On Thursday 02 June 2016 09:39, Lawrence D’Oliveiro wrote: > Also, they let me declare a variable that is scoped to the loop Why do you want variables scoped to the loop? -- Steve -- https://mail.python.org/mailman/listinfo/python-list

Re: for / while else doesn't make sense

2016-06-01 Thread Lawrence D’Oliveiro
On Friday, May 20, 2016 at 4:43:56 AM UTC+12, Herkermer Sherwood wrote: > Most keywords in Python make linguistic sense, but using "else" in for and > while structures is kludgy and misleading. My objection is not to the choice of keyword, it’s to the whole design of the loop construct. It turns

Re: for / while else doesn't make sense

2016-05-29 Thread Marko Rauhamaa
Random832 : > On Thu, May 26, 2016, at 05:05, Marko Rauhamaa wrote: >>3124 16 8 0 >>+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ >>| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >>+-+-+-+-+

Re: for / while else doesn't make sense

2016-05-29 Thread Random832
On Thu, May 26, 2016, at 05:05, Marko Rauhamaa wrote: >3124 16 8 0 >+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ >| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >+-+-+-+-+-+-+-+-+-+-+-+-+-+-

Re: Exended ASCII and code pages [was Re: for / while else doesn't make sense]

2016-05-28 Thread Steven D'Aprano
On Sat, 28 May 2016 01:53 am, Rustom Mody wrote: > On Friday, May 27, 2016 at 7:21:41 PM UTC+5:30, Random832 wrote: >> On Fri, May 27, 2016, at 05:56, Steven D'Aprano wrote: >> > On Fri, 27 May 2016 05:04 pm, Marko Rauhamaa wrote: >> > >> > > They are all ASCII derivatives. Those that aren't don'

Re: Exended ASCII and code pages [was Re: for / while else doesn't make sense]

2016-05-27 Thread Rustom Mody
On Saturday, May 28, 2016 at 12:34:14 AM UTC+5:30, Marko Rauhamaa wrote: > Random832 : > > > On Fri, May 27, 2016, at 05:56, Steven D'Aprano wrote: > >> On Fri, 27 May 2016 05:04 pm, Marko Rauhamaa wrote: > >> > They are all ASCII derivatives. Those that aren't don't exist. > >> *plonk* > > > > Th

Re: Exended ASCII and code pages [was Re: for / while else doesn't make sense]

2016-05-27 Thread Marko Rauhamaa
Random832 : > On Fri, May 27, 2016, at 05:56, Steven D'Aprano wrote: >> On Fri, 27 May 2016 05:04 pm, Marko Rauhamaa wrote: >> > They are all ASCII derivatives. Those that aren't don't exist. >> *plonk* > > That's a bit harsh, Everybody has a right to plonk anybody -- and even declare it ceremoni

  1   2   3   >