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

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder3.xlned.com!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.012
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'stops': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'snippet': 0.09; 'martin': 0.11; 'jan': 0.12; 'loops': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'removed,': 0.16; 'demonstrate': 0.16; 'wrote:': 0.18; 'reset': 0.22; 'header:User-Agent:1': 0.23; 'mon,': 0.24; 'question': 0.24; 'post': 0.26; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'chris': 0.29; 'am,': 0.29; "doesn't": 0.30; 'code': 0.31; 'another': 0.32; 'problem': 0.35; 'problem.': 0.35; 'add': 0.35; 'minimum': 0.38; 'problems': 0.38; 'needed': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'flow': 0.39; 'received:71': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'tell': 0.60; 'more': 0.64; 'jul': 0.74; '(here': 0.84; 'hardly': 0.84; 'noise': 0.84; 'obvious.': 0.84; 'received:fios.verizon.net': 0.84
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Terry Reedy <tjreedy@udel.edu>
Subject Re: complete brain fart, it doesn't loop
Date Sun, 27 Jul 2014 14:17:49 -0400
References <CAHXoDSB=W3S4gwc7aJO2AA6gtkz5VGQ5=y7hZ5tLL32AamjmXQ@mail.gmail.com> <CAPTjJmrdqBwuiuJHSAGCjRZoWsQzi_iFVJe=XD3m0nbGa9w_Cg@mail.gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host pool-71-175-90-87.phlapa.fios.verizon.net
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0
In-Reply-To <CAPTjJmrdqBwuiuJHSAGCjRZoWsQzi_iFVJe=XD3m0nbGa9w_Cg@mail.gmail.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.12365.1406485084.18130.python-list@python.org> (permalink)
Lines 28
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1406485084 news.xs4all.nl 2855 [2001:888:2000:d::a6]:39358
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:75281

Show key headers only | 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