Movatterモバイル変換


[0]ホーム

URL:


[Python-Dev] empty string api for files

Raymond Hettingerraymond.hettinger at verizon.net
Sat Aug 27 17:04:54 CEST 2005


> For reading bytes, I *know* that a lot of code would become uglier if> the API changed to raise EOFError exceptionsI had StopIteration in mind.  Instead of writing:    while 1:        block = f.read(20)        if line == '':            break        . . .We would use:    for block in f.readblocks(20):        . . .More beauty, a little faster, more concise, and less error-prone.  Ofcourse, there are likely better choices for the method name, but you getthe gist of it.


More information about the Python-Devmailing list

[8]ページ先頭

©2009-2025 Movatter.jp