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


Groups > comp.lang.python > #19170

Re: Weird Loop Behaviour

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!tudelft.nl!txtfeed1.tudelft.nl!multikabel.net!newsfeed20.multikabel.net!news2.euro.net!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.003
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'else:': 0.03; 'ok.': 0.04; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; '0))': 0.16; 'received:173.11': 0.16; 'seconds,': 0.16; 'trying': 0.20; 'header :In-Reply-To:1': 0.22; 'figure': 0.23; 'thus': 0.23; 'suspect': 0.24; 'code': 0.25; 'tests': 0.25; 'seconds': 0.25; 'code,': 0.27; 'pass': 0.28; 'values': 0.32; 'header:User-Agent:1': 0.33; 'instead': 0.33; 'to:addr:python-list': 0.33; 'hi,': 0.34; 'setting': 0.34; 'routine': 0.34; 'header:X-Complaints-To:1': 0.34; 'run': 0.37; 'but': 0.37; 'received:org': 0.37; 'getting': 0.37; 'screen': 0.38; 'should': 0.38; "couldn't": 0.39; 'expected': 0.39; 'subject:: ': 0.39; 'move': 0.40; 'to:addr:python.org': 0.40; 'received:173': 0.64; '12:47': 0.84; 'respectively': 0.84
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Emile van Sebille <emile@fenx.com>
Subject Re: Weird Loop Behaviour
Date Fri, 20 Jan 2012 13:20:21 -0800
References <23de2ba8-dccc-404c-92f3-da0023c12646@t2g2000yqk.googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host 173-11-108-137-sfba.hfc.comcastbusiness.net
User-Agent Mozilla/5.0 (Windows NT 5.1; rv:9.0) Gecko/20111222 Thunderbird/9.0.1
In-Reply-To <23de2ba8-dccc-404c-92f3-da0023c12646@t2g2000yqk.googlegroups.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.4898.1327094440.27778.python-list@python.org> (permalink)
Lines 35
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1327094440 news.xs4all.nl 6907 [2001:888:2000:d::a6]:51559
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:19170

Show key headers only | View raw


On 1/20/2012 12:47 PM Yigit Turgut said...
> Hi,
>
> In the following code, I am trying to run "black" screen for 3 seconds
> and respectively 2 seconds "white" screen. Black routine takes 3
> seconds and white 2 seconds, 2 x black + white = 8 seconds which
> should be the expected value but when I run it I get black-white-black-
> white   instead of black-white-black. Couldn't figure out what is
> wrong thus sharing the code as well ;
>
> white = False
>       while(end<8.00):
>        end = time.time() - start
you're setting end's value before the display happens, so while tests 
the values 0,3,5 before getting after the fourth pass 8.  Move this 
after to white = note white and I suspect you'll be OK.

HTH,

Emile




>        if white:
>         screen.fill((255, 255, 255))
> 	time.sleep(2)
>        else:
>        	screen.fill((0, 0, 0))
> 	time.sleep(3)
>        white = not white
>        pygame.display.update()
>       pygame.quit()

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


Thread

Weird Loop Behaviour Yigit Turgut <y.turgut@gmail.com> - 2012-01-20 12:47 -0800
  Re: Weird Loop Behaviour MRAB <python@mrabarnett.plus.com> - 2012-01-20 21:10 +0000
  Re: Weird Loop Behaviour Emile van Sebille <emile@fenx.com> - 2012-01-20 13:20 -0800
  Re: Weird Loop Behaviour Arnaud Delobelle <arnodel@gmail.com> - 2012-01-20 23:10 +0000

csiph-web