Post Reply 
Python survey 2020
11-01-2020, 04:45 PM (This post was last modified: 11-01-2020 04:53 PM by toml_12953.)
Post: #6
RE: Python survey 2020
(11-01-2020 05:59 AM)Wes Loewer Wrote:  I know they won't add it, but Python could use a DO-WHILE or REPEAT-UNTIL or equivalent loop structure where the condition is evaluated at the end of the loop. I don't know that I've ever used a language without such a loop construct. I know you can use a "while True:" and a "break" but that looks so kludgy.

(On the plus side, I don't know that I've seen another language with the while-else construction that Python has. That's kind of cool.)

You can do this:

Code:
while True:
   do something
   do some more
   a += 1
   If a >= 10:
      Break


That's the equivalent of
Code:
DO
   do something
   do some more
   a = a + 1
LOOP WHILE a < 10

I know you think it looks kludgy as did I, coming from a BASIC background, but if you use Python for a while you get used to it. Since Python programmers think in terms of While True, there's no incentive to change it.

Tom L
Cui bono?
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Python survey 2020 - compsystems - 10-30-2020, 02:25 PM
RE: Python survey 2020 - pinkman - 10-30-2020, 08:36 PM
RE: Python survey 2020 - Wes Loewer - 11-01-2020, 05:59 AM
RE: Python survey 2020 - Albert Chan - 11-01-2020, 10:51 AM
RE: Python survey 2020 - toml_12953 - 11-01-2020 04:45 PM
RE: Python survey 2020 - Dave Britten - 11-01-2020, 02:25 PM



User(s) browsing this thread: 1 Guest(s)