Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.048 X-Spam-Evidence: '*H*': 0.91; '*S*': 0.00; 'subject:while': 0.09; 'cc:addr:python-list': 0.10; 'thread': 0.12; 'times,': 0.14; 'message-id:@unknownmsgid': 0.16; 'sleeping': 0.16; 'wrote:': 0.19; 'trying': 0.20; 'least': 0.20; 'print': 0.21; 'header:In- Reply-To:1': 0.22; 'run': 0.25; 'second': 0.25; 'cheers,': 0.26; 'cc:2**0': 0.26; 'said,': 0.27; 'set.': 0.27; 'cc:addr:python.org': 0.28; 'cpu': 0.28; 'text,': 0.28; 'hi,': 0.29; "i'm": 0.29; 'reset': 0.31; 'received:google.com': 0.32; 'probably': 0.32; 'pm,': 0.34; 'received:74.125': 0.35; 'text': 0.35; 'thank': 0.36; 'but': 0.37; 'subject:: ': 0.37; 'means': 0.38; 'this,': 0.40; 'indicate': 0.60; 'real': 0.61; '2012': 0.62; '2012,': 0.84; 'flag.': 0.84; 'ian,': 0.84; 'sec.': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=references:from:in-reply-to:mime-version:date:message-id:subject:to :cc:content-type; bh=NJeTCAHqbfG4a/dk9Hyh8TAbYJ2LwoRJuI+oVUy2HHQ=; b=wmBMBiD5j9dMnTrAT2NCc9H/qaTFJd6WJYGpRsrDiezyvIqxAiLAzr6dXQ69jOtBof HM0a9rsLLqErr9T94t+iN9rwrbMLe7JSGzuo0NvCAx0B2HBExy6bZ4P437gGbgO4K78s 3rk44dSswV02UTHqZnSQTIBBU3PDhN528Xbg3YTH400bAdaCnDN5oxoPui/UP5MNfzXu Z5ulwjsL3USsEX9tM2wVIXIEp61xqcGgHI7vnDRzOyQnp5Xbt6RLPTGkzLi6FbQc8LY6 CF/jJWzaWP8bTukf5y7yDRh6ZeaGyZXA189VmseisIQ5562+EakKcd2jMtseJxzMWJwP GitA== References: <7619907723400632495@unknownmsgid> From: Anatoli Hristov In-Reply-To: Mime-Version: 1.0 (1.0) Date: Tue, 3 Apr 2012 23:00:22 +0200 Subject: Re: Run once while loop To: Ian Kelly Content-Type: text/plain; charset=UTF-8 Cc: "python-list@python.org" X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 31 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1333486831 news.xs4all.nl 6987 [2001:888:2000:d::a6]:44047 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:22638 On 03 Apr 2012, at 22:45, Ian Kelly wrote: > On Tue, Apr 3, 2012 at 2:36 PM, Anatoli Hristov wrote: >> Hi, >> >> I'm trying to do a while loop with condition of time if time is >> 12:00:00 print text, but for this one second the text is printed at >> least 50 times, how can I print only once? > > Set a flag when you print the text to indicate that you've already > printed it, and don't print it again if the flag is set. When it's no > longer 12:00:00, reset the flag. > > That said, a busy while loop is probably the wrong way to do this, > because it will run your CPU at 100%. Better would be to put the > thread to sleep with time.sleep() calls or a real event loop with a > timer event. > > Cheers, > Ian Thank you Ian, what if I wait for other conditions if I use time.sleep for 1 sec? it means that all the program is sleeping for a sec. Regards Hristov Anatoli