[Python-Dev] Wishlist: dowhile

Phillip J. Eby pje at telecommunity.com
Mon Jun 13 18:29:17 CEST 2005


At 08:14 AM 6/13/2005 -0400, Jp Calderone wrote:
>On Mon, 13 Jun 2005 01:25:51 -0400, "Phillip J. Eby" 
><pje at telecommunity.com> wrote:
> >Block-copying a file with read() has the same pattern (e.g. in shutil), but
> >you can't make it a for loop.
>
>Anything can be a for loop.
>
>   for chunk in iter(lambda: f1.read(CHUNK_SIZE), ''):
>       f2.write(chunk)

Showoff.  ;)

More seriously, I think your translation makes an excellent argument in 
*favor* of having a do/while statement for greater clarity.  :)



More information about the Python-Dev mailing list