How to do this in Python?

Matthew Woodcraft matthew at woodcraft.me.uk
Tue Mar 17 23:34:31 CET 2009


Jim Garrison <jgarrison at troux.com> writes:

>         buf = f.read(10000)
>         while len(buf) > 0
>             # do something....
>             buf = f.read(10000)

I think it's more usual to use a 'break' rather than duplicate the read.

That is, something more like

    while True:
        buf = f.read(10000)
        if len(buf) == 0:
            break
        # do something

-M-



More information about the Python-list mailing list