Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed6.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.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'none:': 0.07; 'none)': 0.09; '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; 'subject:problems': 0.09; 'done"': 0.16; 'none"': 0.16; 'received:dip.t-dialin.net': 0.16; 'received:t-dialin.net': 0.16; 'subject:updates': 0.16; 'wrote:': 0.16; '>>>': 0.18; 'from:addr:web.de': 0.23; 'modify': 0.25; 'example': 0.28; 'print': 0.29; 'does': 0.32; 'break': 0.32; 'done': 0.33; 'to:addr :python-list': 0.33; "we're": 0.34; 'header:X-Complaints-To:1': 0.34; 'probably': 0.35; 'received:org': 0.37; 'subject:with': 0.38; 'subject:: ': 0.39; 'might': 0.40; 'to:addr:python.org': 0.40; 'quick': 0.60; 'your': 0.61; '"we\'re': 0.84; 'enlightened': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Peter Otten <__peter__@web.de> Subject: Re: problems with tkinter updates Date: Thu, 26 Jan 2012 14:16:12 +0100 Organization: None References: <27f5c74f-83b1-4f2e-b5be-eca42bfaedb7@t2g2000yqk.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7Bit X-Gmane-NNTP-Posting-Host: p5084a503.dip.t-dialin.net 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: 38 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1327583788 news.xs4all.nl 6868 [2001:888:2000:d::a6]:51548 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:19486 woooee wrote: [Peter Otten] >> line = next(infile, None) >> if line is not None: > if line is not None: probably does not work the way you expect. It does what I expect. > You might try > if line.strip(): > Take a look at this quick example > > test_lines = ["Number 1\n", "\n", ""] > for ctr, line in enumerate(test_lines): > print ctr, line > if line is not None: > print " not None" Modify your example to >>> test_lines = ["Number 1\n", "\n", ""] >>> test_lines = iter(test_lines) >>> while True: ... line = next(test_lines, None) ... if line is None: ... print "we're done" ... break ... print repr(line) ... 'Number 1\n' '\n' '' we're done and be enlightened ;)