problems with tkinter updates
Peter Otten
__peter__ at web.de
Thu Jan 26 08:16:12 EST 2012
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 ;)
More information about the Python-list
mailing list