A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2005-June/054185.html below:

[Python-Dev] Wishlist: dowhile

[Python-Dev] Wishlist: dowhile [Python-Dev] Wishlist: dowhileJp Calderone exarkun at divmod.com
Mon Jun 13 14:14:23 CEST 2005
On Mon, 13 Jun 2005 01:25:51 -0400, "Phillip J. Eby" <pje at telecommunity.com> wrote:
>At 09:01 PM 6/12/2005 -0700, Guido van Rossum wrote:
>>If we have to do this, PEP 315 has my +0.
>>
>>It is Pythonically minimal and the motivation rings true: I've often
>>written code like this in the past:
>>
>>     line = f.readline()
>>     while line:
>>         <do something>
>>         line = f.readline()
>>
>>But these days we do that using "for line in f".
>
>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)

Jp
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4