Re: Trying to understand nested loops

2022-08-08 Thread GB
On 08/08/2022 12:59, Dan Purgert wrote: dn wrote: On 06/08/2022 11.41, avi.e.gr...@gmail.com wrote: I wonder if someone is pulling our leg as they are sending from an invalid email address of "GB " which is a bit sick. There are a number of folk who use evidently false email addresses - the

Re: Trying to understand nested loops

2022-08-08 Thread Dan Purgert
-BEGIN PGP SIGNED MESSAGE- Hash: SHA512 dn wrote: > On 06/08/2022 11.41, avi.e.gr...@gmail.com wrote: >> I wonder if someone is pulling our leg as they are sending from an >> invalid email address of "GB " which is >> a bit sick. > > There are a number of folk who use evidently false

RE: Trying to understand nested loops

2022-08-06 Thread avi.e.gross
On Behalf Of Chris Angelico Sent: Saturday, August 6, 2022 8:12 AM To: python-list@python.org Subject: Re: Trying to understand nested loops On Sat, 6 Aug 2022 at 22:08, Richard Damon wrote: > > On 8/6/22 12:01 AM, Chris Angelico wrote: > > On Sat, 6 Aug 2022 at 13:54, Dan Stromberg wrote:

Re: Trying to understand nested loops

2022-08-06 Thread Chris Angelico
On Sat, 6 Aug 2022 at 22:39, Richard Damon wrote: > > On 8/6/22 8:12 AM, Chris Angelico wrote: > > On Sat, 6 Aug 2022 at 22:08, Richard Damon wrote: > >> On 8/6/22 12:01 AM, Chris Angelico wrote: > >>> On Sat, 6 Aug 2022 at 13:54, Dan Stromberg wrote: > On Fri, Aug 5, 2022 at 12:54 PM

Re: Trying to understand nested loops

2022-08-06 Thread Richard Damon
On 8/6/22 8:12 AM, Chris Angelico wrote: On Sat, 6 Aug 2022 at 22:08, Richard Damon wrote: On 8/6/22 12:01 AM, Chris Angelico wrote: On Sat, 6 Aug 2022 at 13:54, Dan Stromberg wrote: On Fri, Aug 5, 2022 at 12:54 PM Grant Edwards wrote: In C, this doesn't do what it looks like it's

Re: Trying to understand nested loops

2022-08-06 Thread Chris Angelico
On Sat, 6 Aug 2022 at 22:08, Richard Damon wrote: > > On 8/6/22 12:01 AM, Chris Angelico wrote: > > On Sat, 6 Aug 2022 at 13:54, Dan Stromberg wrote: > >> On Fri, Aug 5, 2022 at 12:54 PM Grant Edwards > >> wrote: > >> > >>> In C, this doesn't do what it looks like it's supposed to do. > >>> >

Re: Trying to understand nested loops

2022-08-06 Thread Richard Damon
On 8/6/22 12:01 AM, Chris Angelico wrote: On Sat, 6 Aug 2022 at 13:54, Dan Stromberg wrote: On Fri, Aug 5, 2022 at 12:54 PM Grant Edwards wrote: In C, this doesn't do what it looks like it's supposed to do. if (foo) do_this(); and_this(); then_do_this(); It's been

Re: Trying to understand nested loops

2022-08-05 Thread Chris Angelico
On Sat, 6 Aug 2022 at 13:54, Dan Stromberg wrote: > > On Fri, Aug 5, 2022 at 12:54 PM Grant Edwards > wrote: > > > In C, this doesn't do what it looks like it's supposed to do. > > > >if (foo) > > do_this(); > > and_this(); > >then_do_this(); > > > It's been quite a while since

Re: Trying to understand nested loops

2022-08-05 Thread Dan Stromberg
On Fri, Aug 5, 2022 at 12:54 PM Grant Edwards wrote: > In C, this doesn't do what it looks like it's supposed to do. > >if (foo) > do_this(); > and_this(); >then_do_this(); > It's been quite a while since I used C, but with the right compiler flag(s), I think this may be a

Re: Trying to understand nested loops

2022-08-05 Thread Mladen Gogala via Python-list
On Fri, 5 Aug 2022 08:34:45 +0100, ojomooluwatolami675 wrote: > Hello, I’m new to learning python and I stumbled upon a question nested > loops. This is the question below. Can you please how they arrived at 9 > as the answer. Thanks > > var = 0 for i in range(3): > for j

RE: Trying to understand nested loops

2022-08-05 Thread avi.e.gross
to write articles or books and wants to see what people think but then does not participate or tell us that is what they wanted. My point was not to tell anyone else here what to do, simply that I will be cautious with such posters as I have way better things to do! Nested loops are indeed a hard

Re: Trying to understand nested loops

2022-08-05 Thread dn
On 06/08/2022 11.41, avi.e.gr...@gmail.com wrote: > I wonder if someone is pulling our leg as they are sending from an invalid > email address of "GB " which is a bit sick. There are a number of folk who use evidently false email addresses - the OP's had me amused. Such 'hiding' is a matter for

Re: Trying to understand nested loops

2022-08-05 Thread Dan Stromberg
On Fri, Aug 5, 2022 at 12:30 PM GB wrote: > On 05/08/2022 08:56, Frank Millman wrote: > > > BTW, there is an indentation error in your original post - line 5 should > > line up with line 4. > > As a Python beginner, I find that Python is annoyingly picky about > indents. And, the significance

RE: Trying to understand nested loops

2022-08-05 Thread avi.e.gross
r at least that they have spent any serious time learning. -Original Message- From: Python-list On Behalf Of GB Sent: Friday, August 5, 2022 5:57 AM To: python-list@python.org Subject: Re: Trying to understand nested loops On 05/08/2022 08:56, Frank Millman wrote: > BTW, there is an inde

Re: Trying to understand nested loops

2022-08-05 Thread dn
On 06/08/2022 10.50, Dan Stromberg wrote: > On Fri, Aug 5, 2022 at 12:35 AM wrote: ... > Of if you don't have (or want) a debugger, you could change it to: > > var = 0 > for i in range(3): > print('i is', i) > for j in range(-2,-7,-2): > print('j is', j) > var += 1 > print(var)

Re: Trying to understand nested loops

2022-08-05 Thread Dan Stromberg
On Fri, Aug 5, 2022 at 12:35 AM wrote: > Hello, I’m new to learning python and I stumbled upon a question nested > loops. This is the question below. Can you please how they arrived at 9 as > the answer. Thanks > > var = 0 > for i in range(3): > for j in range(-2,-

Re: Trying to understand nested loops

2022-08-05 Thread Mats Wichmann
On 8/5/22 03:56, GB wrote: > On 05/08/2022 08:56, Frank Millman wrote: > >> BTW, there is an indentation error in your original post - line 5 >> should line up with line 4. > > As a Python beginner, I find that Python is annoyingly picky about > indents.  And, the significance of indents is a

Re: Trying to understand nested loops

2022-08-05 Thread Grant Edwards
On 2022-08-05, GB wrote: >> BTW, there is an indentation error in your original post - line 5 >> should line up with line 4. > > As a Python beginner, I find that Python is annoyingly picky about > indents. And, the significance of indents is a bit of a minefield for > beginners. As a C

Re: Trying to understand nested loops

2022-08-05 Thread GB
On 05/08/2022 08:56, Frank Millman wrote: BTW, there is an indentation error in your original post - line 5 should line up with line 4. As a Python beginner, I find that Python is annoyingly picky about indents. And, the significance of indents is a bit of a minefield for beginners. For

Re: Trying to understand nested loops

2022-08-05 Thread Dieter Maurer
ojomooluwatolami...@gmail.com wrote at 2022-8-5 08:34 +0100: >Hello, I’m new to learning python and I stumbled upon a question nested loops. For future, more complex, questions of this kind, you might have a look at the module `pdb` in Python's runtime library. It implements a debugger wh

Re: Trying to understand nested loops

2022-08-05 Thread Weatherby,Gerard
It’s also a poor code example. Doing a pointless double loop is not good instructional practice, especially when simpler alternatives exist. e.g. for i in range(3): for j in range(-2.-7,-2): print(i +j ) — Gerard Weatherby | Application Architect NMRbox | NAN | Department of Molecular

Re: Trying to understand nested loops

2022-08-05 Thread Cameron Simpson
On 05Aug2022 09:47, Lars Liedtke wrote: >this looks to me like it might be a piece of homework, as it would be >given by teachers or professors. > >This list has got the rule, that members do not solve other's >homework. Because very often homework is meant to sit down and think >about it.

Re: Trying to understand nested loops

2022-08-05 Thread Frank Millman
On 2022-08-05 9:34 AM, ojomooluwatolami...@gmail.com wrote: Hello, I’m new to learning python and I stumbled upon a question nested loops. This is the question below. Can you please how they arrived at 9 as the answer. Thanks var = 0 for i in range(3): for j in range(-2,-7,-2): var

Re: Trying to understand nested loops

2022-08-05 Thread Lars Liedtke
:34 schrieb ojomooluwatolami...@gmail.com: Hello, I’m new to learning python and I stumbled upon a question nested loops. This is the question below. Can you please how they arrived at 9 as the answer. Thanks var = 0 for i in range(3): for j in range(-2,-7,-2): var += 1 print(var

Trying to understand nested loops

2022-08-05 Thread ojomooluwatolami675
Hello, I’m new to learning python and I stumbled upon a question nested loops. This is the question below. Can you please how they arrived at 9 as the answer. Thanks var = 0 for i in range(3): for j in range(-2,-7,-2): var += 1 print(var) Sent from my iPhone -- https

[issue406563] test_long loops openbsd2.8 i386

2022-04-10 Thread admin
Change by admin : -- github: None -> 34111 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue210681] memory leak in loops (PR#398)

2022-04-10 Thread admin
Change by admin : ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue210681] memory leak in loops (PR#398)

2022-04-10 Thread admin
Change by admin : -- github: None -> 32751 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue47190] Integrating tkinter and asyncio event loops

2022-04-04 Thread Terry J. Reedy
Terry J. Reedy added the comment: That issue has my previous experiments. Thank you Serhiy for finding it ;-). -- resolution: -> duplicate superseder: -> Integrate tkinter and asyncio (and async) ___ Python tracker

[issue47190] Integrating tkinter and asyncio event loops

2022-04-04 Thread Skip Montanaro
Skip Montanaro added the comment: That's fine. My brief search didn't turn up https://bugs.python.org/issue27546 I'm happy to close this. -- stage: patch review -> resolved status: open -> closed ___ Python tracker

[issue47190] Integrating tkinter and asyncio event loops

2022-04-04 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: It is a duplicate of issue27546. -- nosy: +serhiy.storchaka ___ Python tracker ___ ___

[issue47190] Integrating tkinter and asyncio event loops

2022-04-03 Thread Skip Montanaro
Change by Skip Montanaro : -- keywords: +patch pull_requests: +30355 stage: -> patch review pull_request: https://github.com/python/cpython/pull/32293 ___ Python tracker ___

[issue47190] Integrating tkinter and asyncio event loops

2022-04-01 Thread Terry J. Reedy
Terry J. Reedy added the comment: I did some somewhat similar experiments a few years ago. I will try to find the code sometime. -- nosy: +terry.reedy ___ Python tracker

[issue47190] Integrating tkinter and asyncio event loops

2022-04-01 Thread Skip Montanaro
New submission from Skip Montanaro : After looking around and asking, it appears there is no built-in integration of the tkinter and asyncio event loops. That would seem to be a good thing, at least as an example. I wrote a simple hello world which creates an AsyncTk class and uses asyncio

[issue44036] asyncio SSL server can be DOSed, event loop gets blocked: busy loops and uses 100% CPU

2022-03-25 Thread Andrew Svetlov
Andrew Svetlov added the comment: Could you check Python 3.11? It has a new asyncio SSL implementation rewritten from scratch. -- ___ Python tracker ___

[issue40811] Allow to create new Event Loops on Threads

2022-03-17 Thread Andrew Svetlov
Andrew Svetlov added the comment: I suggest closing. The documentation explicitly describes how asyncio works with threads. -- resolution: -> wont fix stage: patch review -> resolved status: open -> closed ___ Python tracker

[issue46855] printing a string with strange characters loops forever

2022-02-26 Thread Éric Araujo
Éric Araujo added the comment: Note that the original issue seems to be that you had bytes but pasted it as a unicode string. This works: >>> b = b'Betrag gr\xc3\xb6\xc3\x9fer als Betrag der Original-Transaktion' >>> s = b.decode('utf-8') >>> print(s) Betrag größer als Betrag der

[issue46855] printing a string with strange characters loops forever

2022-02-25 Thread svilen dobrev
svilen dobrev added the comment: aha. ctrl-s also closes it. seems kind-of ( ctrl-q - ctrl-s ) https://en.wikipedia.org/wiki/Software_flow_control thanks, closing this. -- resolution: -> not a bug stage: -> resolved status: open -> closed ___

[issue46855] printing a string with strange characters loops forever

2022-02-25 Thread Eryk Sun
Eryk Sun added the comment: The ordinal range 0x80-0x9F is the C1 control code set [1]. Ordinal 0x9F is "Application Program Command" (APC). The command must be terminated by ordinal 0x9C, "String Terminator" (ST). For example, "\x9f Some Command \x9c". In Gnome Terminal, after executing

[issue46844] Implicit binding of PersistentTaskGroup (or virtual event loops)

2022-02-25 Thread Guido van Rossum
Guido van Rossum added the comment: Let's concentrate the discussion in the other issue. -- resolution: -> wont fix stage: -> resolved status: open -> closed ___ Python tracker

[issue46855] printing a string with strange characters loops forever

2022-02-25 Thread svilen dobrev
f-8 representation, with forgotten "b" infront of it. -- components: Interpreter Core messages: 414010 nosy: svild priority: normal severity: normal status: open title: printing a string with strange characters loops forever type: behavior versions: Python 3.10

[issue46844] Implicit binding of PersistentTaskGroup (or virtual event loops)

2022-02-24 Thread Joongi Kim
Joongi Kim added the comment: Updated the title to reduce confusion. -- title: Context-based TaskGroup for legacy libraries -> Implicit binding of PersistentTaskGroup (or virtual event loops) ___ Python tracker <https://bugs.python.org/issu

[issue45975] Simplify some while-loops with walrus operator

2022-02-03 Thread miss-islington
miss-islington added the comment: New changeset cf7cb1a2bf40516dc571d1d90c12b632dcd9b8c8 by Miss Islington (bot) in branch '3.9': bpo-45975: IDLE - Remove extraneous parens (GH-31107) https://github.com/python/cpython/commit/cf7cb1a2bf40516dc571d1d90c12b632dcd9b8c8 --

[issue45975] Simplify some while-loops with walrus operator

2022-02-03 Thread miss-islington
miss-islington added the comment: New changeset 63523e7b2a631f28134b25a8063d50e08c741db6 by Miss Islington (bot) in branch '3.10': bpo-45975: IDLE - Remove extraneous parens (GH-31107) https://github.com/python/cpython/commit/63523e7b2a631f28134b25a8063d50e08c741db6 --

[issue45975] Simplify some while-loops with walrus operator

2022-02-03 Thread miss-islington
Change by miss-islington : -- pull_requests: +29293 pull_request: https://github.com/python/cpython/pull/31110 ___ Python tracker ___

[issue45975] Simplify some while-loops with walrus operator

2022-02-03 Thread miss-islington
Change by miss-islington : -- pull_requests: +29292 pull_request: https://github.com/python/cpython/pull/31109 ___ Python tracker ___

[issue45975] Simplify some while-loops with walrus operator

2022-02-03 Thread Terry J. Reedy
Terry J. Reedy added the comment: New changeset 916d0d822c79933f4c420f7a36f16f3eb788646b by Terry Jan Reedy in branch 'main': bpo-45975: IDLE - Remove extraneous parens (GH-31107) https://github.com/python/cpython/commit/916d0d822c79933f4c420f7a36f16f3eb788646b --

[issue45975] Simplify some while-loops with walrus operator

2022-02-03 Thread Terry J. Reedy
Change by Terry J. Reedy : -- pull_requests: +29290 pull_request: https://github.com/python/cpython/pull/31107 ___ Python tracker ___

[issue45975] Simplify some while-loops with walrus operator

2022-02-02 Thread Terry J. Reedy
Terry J. Reedy added the comment: New changeset fafd2dadf63973a04f5693e5be19f3e7521c10d4 by Terry Jan Reedy in branch '3.9': [3.9] bpo-45975: Use walrus operator for some idlelib while loops (GH-31083) https://github.com/python/cpython/commit/fafd2dadf63973a04f5693e5be19f3e7521c10d4

[issue45975] Simplify some while-loops with walrus operator

2022-02-02 Thread Terry J. Reedy
Change by Terry J. Reedy : -- pull_requests: +29277 pull_request: https://github.com/python/cpython/pull/31092 ___ Python tracker ___

[issue45975] Simplify some while-loops with walrus operator

2022-02-02 Thread miss-islington
miss-islington added the comment: New changeset 2ddc278875f789de622262ee8ff5a1c3788f031c by Miss Islington (bot) in branch '3.10': bpo-45975: Use walrus operator for some idlelib while loops (GH-31083) https://github.com/python/cpython/commit/2ddc278875f789de622262ee8ff5a1c3788f031c

[issue45975] Simplify some while-loops with walrus operator

2022-02-02 Thread miss-islington
Change by miss-islington : -- nosy: +miss-islington nosy_count: 6.0 -> 7.0 pull_requests: +29276 pull_request: https://github.com/python/cpython/pull/31091 ___ Python tracker

[issue45975] Simplify some while-loops with walrus operator

2022-02-02 Thread Terry J. Reedy
Terry J. Reedy added the comment: New changeset 51a95be1d035a717ab29e98056b8831a98e61125 by Nick Drozd in branch 'main': bpo-45975: Use walrus operator for some idlelib while loops (GH-31083) https://github.com/python/cpython/commit/51a95be1d035a717ab29e98056b8831a98e61125

[issue45975] Simplify some while-loops with walrus operator

2022-02-02 Thread Nick Drozd
Change by Nick Drozd : -- keywords: +patch pull_requests: +29267 stage: -> patch review pull_request: https://github.com/python/cpython/pull/31083 ___ Python tracker ___

[issue45975] Simplify some while-loops with walrus operator

2022-01-26 Thread Terry J. Reedy
Terry J. Reedy added the comment: To me, the five idlelib changes make the code easier to understand. Nick, please either move them into a separate PR or allow me to do so, and subject to manual testing, I will merge and backport. (I requested this on the PR by maybe you missed it.) If

[issue46225] f_lasti behaves differently for lambdas returned from loops

2022-01-09 Thread Ned Batchelder
Ned Batchelder added the comment: Thanks, it does help. While updating coverage.py to use the RESUME information, I found another problem: https://bugs.python.org/issue46314 -- ___ Python tracker

[issue46225] f_lasti behaves differently for lambdas returned from loops

2022-01-06 Thread Mark Shannon
Mark Shannon added the comment: Are you using `f_lasti == -1` as a proxy for "is this an actual call or a resumption after a yield"? Ultimately PEP 669 will provide all the information you could need to differentiate different events. In the meantime... We now make all "call" events

[issue46225] f_lasti behaves differently for lambdas returned from loops

2022-01-02 Thread Ned Batchelder
Ned Batchelder added the comment: Also, this only happens with a Python trace function. With a C trace function, pPyFrameObject->f_frame->f_lasti is -1. -- ___ Python tracker

[issue46225] f_lasti behaves differently for lambdas returned from loops

2022-01-02 Thread Ned Batchelder
: return lambda: 99 99 -- keywords: 3.11regression messages: 409496 nosy: Mark.Shannon, nedbat priority: normal severity: normal status: open title: f_lasti behaves differently for lambdas returned from loops versions: Python 3.11 ___ Python trac

[issue45975] Simplify some while-loops with walrus operator

2021-12-04 Thread Alex Waygood
Change by Alex Waygood : -- nosy: +AlexWaygood ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue45975] Simplify some while-loops with walrus operator

2021-12-04 Thread Nick Drozd
Nick Drozd added the comment: > Is there any measurable performance benefit from this? I wouldn't expect any performance changes either way. If it worked out to be slower, that would an unpleasant surprise and a good reason to reject this change. If it worked out to be faster, well, that

[issue45975] Simplify some while-loops with walrus operator

2021-12-04 Thread Raymond Hettinger
Raymond Hettinger added the comment: > As I mentioned in the PR, merging this can make future > backports to 3.6 and 3.7 more complicated. That's correct, but it is also true that we do very few of those and the likelihood of a conflict with one of these edits is low. --

[issue45975] Simplify some while-loops with walrus operator

2021-12-04 Thread Irit Katriel
Irit Katriel added the comment: As I mentioned in the PR, merging this can make future backports to 3.6 and 3.7 more complicated. -- nosy: +iritkatriel ___ Python tracker

[issue45975] Simplify some while-loops with walrus operator

2021-12-03 Thread Raymond Hettinger
Raymond Hettinger added the comment: The general rule as stated by Zachary is correct; however, I'm in mildly favor of this PR because these are the use cases that the walrus operator was specifically designed for. That said, it would be nice to verify that timings don't get worse and to

[issue45975] Simplify some while-loops with walrus operator

2021-12-03 Thread Zachary Ware
Zachary Ware added the comment: As a general rule, refactorings like this tend to be rejected as the risk of inadvertently adding a new bug outweighs the benefit of subjectively cleaner code ("if it ain't broke, don't fix it!"). Is there any measurable performance benefit from this?

[issue45975] Simplify some while-loops with walrus operator

2021-12-03 Thread Nick Drozd
some while-loops with walrus operator versions: Python 3.11 ___ Python tracker <https://bugs.python.org/issue45975> ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue20742] 2to3 zip fixer doesn't fix for loops.

2021-10-20 Thread Irit Katriel
Change by Irit Katriel : -- resolution: -> duplicate stage: -> resolved status: open -> closed superseder: -> Close 2to3 issues and list them here ___ Python tracker ___

[issue44036] asyncio SSL server can be DOSed, event loop gets blocked: busy loops and uses 100% CPU

2021-10-10 Thread Christian Heimes
Change by Christian Heimes : -- assignee: christian.heimes -> components: -SSL ___ Python tracker ___ ___ Python-bugs-list

[issue44036] asyncio SSL server can be DOSed, event loop gets blocked: busy loops and uses 100% CPU

2021-10-10 Thread Neil Booth
Change by Neil Booth : -- nosy: +kyuupichan ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

RE: Friday Finking: Contorted loops

2021-09-13 Thread Avi Gross via Python-list
on.org Subject: Re: Friday Finking: Contorted loops On 2021-09-12 17:11:58 -0400, Avi Gross via Python-list wrote: > Yes, large units of code, and even smaller ones, may be a chore to > figure out. Arguably harder when you use indentation and the next/last > parts are not even on the same scr

Re: Friday Finking: Contorted loops

2021-09-13 Thread Peter J. Holzer
ILE clause controlling it at the end. > > do { # until the while clause below > > } while # End of the do loop. Because those comments don't tell me anything that I as a C programmer don't already know. Even though do/while loops are relatively rare, I've seen hundreds of them. Seein

Re: Friday Finking: Contorted loops

2021-09-12 Thread Alan Gauld via Python-list
On 12/09/2021 09:11, jak wrote: > if the only way to terminate a 'while True' loop is by using the 'break' > statement, why is it allowed to add the 'else' statement which will only > contain dead code? > > while True: > break > else: > print('dead code') > Because to the

RE: Friday Finking: Contorted loops

2021-09-12 Thread Avi Gross via Python-list
loop. My code tends to have brief comments especially when I have nested constructs such as multiple nested loops or in sequence, or if statements inside others. The comment often looks like ... # END of inner if ... # END of outer if The point is that places where the way of writing a program

Re: Friday Finking: Contorted loops

2021-09-12 Thread Peter J. Holzer
On 2021-09-12 10:28:22 -0700, 2qdxy4rzwzuui...@potatochowder.com wrote: > On 2021-09-11 at 18:21:17 +0100, > Alan Gauld via Python-list wrote: > > On 11/09/2021 15:41, Peter J. Holzer wrote: > > > How is C's do/while loop more horrible than Pascal's repeat/until? [...] > > so code that has > >

RE: Friday Finking: Contorted loops

2021-09-12 Thread Avi Gross via Python-list
needs to do things in the current environment and thus only part of the functionality can be moved away. -Original Message- From: Python-list On Behalf Of Stefan Ram Sent: Saturday, September 11, 2021 10:56 PM To: python-list@python.org Subject: Re: Friday Finking: Contorted loops &quo

RE: Friday Finking: Contorted loops

2021-09-12 Thread Avi Gross via Python-list
The topic of looping and our current discussion stimulates me to ask if someone has categorized the uses of loops and it seems something obvious. Once you know what kinds of loopy looping there are, it can get easier to decide which, if any, of the methods to set up a loop make more sense

Re: Friday Finking: Contorted loops

2021-09-12 Thread 2QdxY4RzWzUUiLuE
On 2021-09-11 at 18:21:17 +0100, Alan Gauld via Python-list wrote: > On 11/09/2021 15:41, Peter J. Holzer wrote: > > > How is C's do/while loop more horrible than Pascal's repeat/until? > > Because it is very hard to spot or distinguish from a normal > while loop. > > while condition ; > >

Re: Friday Finking: Contorted loops

2021-09-12 Thread jak
ulness! -Original Message- From: Python-list On Behalf Of Alan Gauld via Python-list Sent: Saturday, September 11, 2021 3:59 AM To: python-list@python.org Subject: Re: Friday Finking: Contorted loops On 10/09/2021 19:49, Stefan Ram wrote: Alan Gauld writes: OK, That's a useful perspe

Re: Friday Finking: Contorted loops

2021-09-12 Thread alister via Python-list
On Sun, 12 Sep 2021 10:11:15 +0200, jak wrote: > -- snip -- >> >> An inconsistency that I have been able to notice is this: >> someone suggests to remedy the absence of the do-while with: >> while True: >> ... >> if condition: >> break >> the problem arises if the while has

Re: Friday Finking: Contorted loops

2021-09-12 Thread Joe Pfeiffer
r...@zedat.fu-berlin.de (Stefan Ram) writes: > Alan Gauld writes: >>OK, That's a useful perspective that is at least consistent. >>Unfortunately it's not how beginners perceive it > ... > > Beginners perceive it the way it is explained to them by > their teacher. My life as a professor

Re: Friday Finking: Contorted loops

2021-09-12 Thread jak
-- snip -- An inconsistency that I have been able to notice is this: someone suggests to remedy the absence of the do-while with: while True: ... if condition: break the problem arises if the while has an else of its own because the break not only blocks the while loop but

Re: Friday Finking: Contorted loops

2021-09-12 Thread Alan Gauld via Python-list
mall C programs of mine I find: > > 35 regular for loops > 28 while loops > 2 infinite for loops > 1 "infinite" for loop (i.e. it exits somewhere in the middle) > 0 do/while loops. That wouldn't surprise me, I've only used do/while in C a handful of times. But in Pasc

Re: Friday Finking: Contorted loops

2021-09-12 Thread Peter J. Holzer
On 2021-09-11 21:38:02 -0400, Avi Gross via Python-list wrote: > Peter, in your own personal finite sample, I am wondering what you might do > TODAY if you looked at your loops again and considered redoing them for an > assortment of reasons ranging from using the code for teaching to e

RE: Friday Finking: Contorted loops

2021-09-11 Thread Avi Gross via Python-list
Peter, in your own personal finite sample, I am wondering what you might do TODAY if you looked at your loops again and considered redoing them for an assortment of reasons ranging from using the code for teaching to efficiency to just fitting your mood better? I have seen seasoned authors go

RE: Friday Finking: Contorted loops

2021-09-11 Thread Avi Gross via Python-list
n Behalf Of Alan Gauld via Python-list Sent: Saturday, September 11, 2021 3:59 AM To: python-list@python.org Subject: Re: Friday Finking: Contorted loops On 10/09/2021 19:49, Stefan Ram wrote: > Alan Gauld writes: >> OK, That's a useful perspective that is at least consistent. >> Unf

Re: Friday Finking: Contorted loops

2021-09-11 Thread Alan Gauld via Python-list
On 10/09/2021 19:49, Stefan Ram wrote: > Alan Gauld writes: >> OK, That's a useful perspective that is at least consistent. >> Unfortunately it's not how beginners perceive it > ... > > Beginners perceive it the way it is explained to them by > their teacher. I'm not sure that's true. Most

Re: Friday Finking: Contorted loops

2021-09-11 Thread Peter J. Holzer
re any empirical evidence to support this? > Or is it just a case of using the tools that are available? > In my experience of using Pascal (and much later with Delphi) > that I used repeat loops at least as often as while loops, > possibly more. > > But using Python and to a lesser exten

Re: Friday Finking: Contorted loops

2021-09-10 Thread Joe Pfeiffer
2qdxy4rzwzuui...@potatochowder.com writes: > On 2021-09-10 at 15:08:19 -0600, > Joe Pfeiffer wrote: > >> r...@zedat.fu-berlin.de (Stefan Ram) writes: > >> > The existence of statements like "break" renders >> > proof techniques for loops

Re: Friday Finking: Contorted loops

2021-09-10 Thread Terry Reedy
On 9/10/2021 7:38 AM, Alan Gauld via Python-list wrote: But python complicates this tenet still further by adding an else clause to its loops. And complicating this still more is that these else clauses have almost exactly opposite effects. To the contrary... if...else executes the else part

Re: Friday Finking: Contorted loops

2021-09-10 Thread 2QdxY4RzWzUUiLuE
On 2021-09-10 at 15:08:19 -0600, Joe Pfeiffer wrote: > r...@zedat.fu-berlin.de (Stefan Ram) writes: > > The existence of statements like "break" renders > > proof techniques for loops (such as Hoare's) with > > their invariants and inference rules una

RE: Friday Finking: Contorted loops

2021-09-10 Thread Avi Gross via Python-list
logically there is if not for the convoluted code to avoid it. Similarly, can most "while" loops that you want to be "until" loops not be made with a bit of code? I mean set first_time to True before starting. Set your while condition to while first_time OR condition or some othe

RE: Friday Finking: Contorted loops

2021-09-10 Thread Avi Gross via Python-list
over and over for "if" statements and perhaps some kind of case/switch statement and while loops and so on, may be parsimonious but ... -Original Message- From: Python-list On Behalf Of Alan Gauld via Python-list Sent: Friday, September 10, 2021 11:58 AM To: python-list@pytho

Re: Friday Finking: Contorted loops

2021-09-10 Thread Joe Pfeiffer
should always be on the watch when reading source code >>of a language like Python than relying only on the condition >>behind the "while". > > The existence of statements like "break" renders > proof techniques for loops (such as Hoare's) wit

Re: Friday Finking: Contorted loops

2021-09-10 Thread Alan Gauld via Python-list
On 10/09/2021 16:36, MRAB wrote: >> while...else... >> >> executes the else if the body of the loop does NOT get executed. >> >> for...else... >> >> executes the else iff ALL iterations of the for loop DO complete. >> > [snip] > > In both cases, it executes the 'else' part if it didn't break out

Re: Friday Finking: Contorted loops

2021-09-10 Thread MRAB
by their nature (or should be!) As such they can arguably be excused from the SP strictures. But python complicates this tenet still further by adding an else clause to its loops. And complicating this still more is that these else clauses have almost exactly opposite effects. while...else... executes

Re: Friday Finking: Contorted loops

2021-09-10 Thread Alan Gauld via Python-list
are available? In my experience of using Pascal (and much later with Delphi) that I used repeat loops at least as often as while loops, possibly more. But using Python and to a lesser extent C (which has a rather horrible do/while) construct I use while loops (often with an if-break) simply because tha

Re: Friday Finking: Contorted loops

2021-09-10 Thread Alan Gauld via Python-list
arguably be excused from the SP strictures. But python complicates this tenet still further by adding an else clause to its loops. And complicating this still more is that these else clauses have almost exactly opposite effects. while...else... executes the else if the body of the loop does NOT get

Re: Friday Finking: Contorted loops

2021-09-10 Thread Greg Ewing
On 10/09/21 11:47 am, Terry Reedy wrote: 2. It is rare useful.  For loops are common.  While loops are occasional (nearly an order of magnitude less common than for loops.  Fractional loop constructs are rare. I would say that fractional loops are more common than loops which truly need

Re: Friday Finking: Contorted loops

2021-09-09 Thread Dennis Lee Bieber
On Thu, 09 Sep 2021 19:07:49 -0400, Dennis Lee Bieber declaimed the following: >On Fri, 10 Sep 2021 09:36:36 +1200, dn via Python-list > declaimed the following: Someone, please shoot me now... >>This is a perennial question (one contributor calling it "immemorial"), >>but there seem

Re: Friday Finking: Contorted loops

2021-09-09 Thread 2QdxY4RzWzUUiLuE
On 2021-09-09 at 22:33:16 +, Stefan Ram wrote: > One can think of a language where every loop is exited this > way, the only loop construct would be > > loop > ... > > and it would /always/ have to be exited via enclosed breaks. I'm not quite sure what you mean by "one can," but

  1   2   3   4   5   6   7   8   9   10   >