Implementing file reading in C/Python
Steven D'Aprano
steve at REMOVE-THIS-cybersource.com.au
Fri Jan 9 05:17:36 EST 2009
On Fri, 09 Jan 2009 09:15:20 +0000, Marc 'BlackJack' Rintsch wrote:
>> picture = { }
>> havepixels = 0
>> while True:
>> data = f.read(blocksize)
>> if len(data) <= 0: break
>
> if data:
> break
>
> is enough.
You've reversed the sense of the test. The OP exits the loop when data is
empty, you exit the loop when it *isn't* empty.
--
Steven
More information about the Python-list
mailing list