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


Groups > comp.lang.python > #19486

Re: problems with tkinter updates

From Peter Otten <__peter__@web.de>
Subject Re: problems with tkinter updates
Date 2012-01-26 14:16 +0100
Organization None
References <FxnTq.4267$5r2.3946@newsfe11.iad> <mailman.5022.1327398783.27778.python-list@python.org> <27f5c74f-83b1-4f2e-b5be-eca42bfaedb7@t2g2000yqk.googlegroups.com>
Newsgroups comp.lang.python
Message-ID <mailman.5123.1327583788.27778.python-list@python.org> (permalink)

Show all headers | View raw


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 ;)

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


Thread

problems with tkinter updates yves@zioup.com - 2012-01-23 18:09 -0700
  Re: problems with tkinter updates Dave Angel <d@davea.name> - 2012-01-23 22:57 -0500
    Re: problems with tkinter updates yves@zioup.com - 2012-01-23 23:47 -0700
  Re: problems with tkinter updates Peter Otten <__peter__@web.de> - 2012-01-24 10:52 +0100
    Re: problems with tkinter updates woooee <woooee@gmail.com> - 2012-01-24 09:50 -0800
      Re: problems with tkinter updates Peter Otten <__peter__@web.de> - 2012-01-26 14:16 +0100
    Re: problems with tkinter updates yves@zioup.com - 2012-01-27 07:02 -0700
      Re: problems with tkinter updates yves@zioup.com - 2012-01-29 10:34 -0700

csiph-web