Arent these snippets equivalent?

Coolgg gauravj123 at gmail.com
Wed Jan 23 16:56:22 EST 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