Arent these snippets equivalent?

Coolgg gauravj123 at gmail.com
Wed Jan 23 22:56:22 CET 2013


Is this:

while True:
    data = fp.read(4096)
    if not data:
        break
    ...

not equivalent to this:

data = fp.read (4096)
while data:
    ...{handle the chunk here}
    data = fp.read (4096)

Heres the article that sparked this question:
http://wordaligned.org/articles/pythons-lesser-known-loop-control




More information about the Python-list mailing list