Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #75281

Re: complete brain fart, it doesn't loop

From Terry Reedy <tjreedy@udel.edu>
Subject Re: complete brain fart, it doesn't loop
Date 2014-07-27 14:17 -0400
References <CAHXoDSB=W3S4gwc7aJO2AA6gtkz5VGQ5=y7hZ5tLL32AamjmXQ@mail.gmail.com> <CAPTjJmrdqBwuiuJHSAGCjRZoWsQzi_iFVJe=XD3m0nbGa9w_Cg@mail.gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.12365.1406485084.18130.python-list@python.org> (permalink)

Show all headers | View raw


On 7/27/2014 1:55 PM, Chris Angelico wrote:
> On Mon, Jul 28, 2014 at 3:53 AM, Martin S <shieldfire@gmail.com> wrote:
>> I have this snippet in my web application. Question is why doesn't the
>> stupid thing loop ten times? It loops exactly 1 time.

One thing we repeatedly tell people who post code with problems (here or 
on the tracker) is to reduce it to the minimun needed to demonstrate the 
problem.  The reason is the with noise removed, the cause is more obvious.

>>    # Reset counter
>>      counter = 0
>>
>>      while counter <= 10:
>>          return "<p>Long line with games</p>"
>>          counter=counter+1

Chris did the reduction for you, and ...

> When you hit the 'return', it stops the function immediately :)

the problem can hardly be missed.

Another approach is to start with the minimum that exhibits the control 
flow you want and then add content.

-- 
Terry Jan Reedy

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: complete brain fart, it doesn't loop Terry Reedy <tjreedy@udel.edu> - 2014-07-27 14:17 -0400

csiph-web