[Python-ideas] Deprecate str.find

Georg Brandl g.brandl at gmx.net
Fri Jul 15 21:49:34 CEST 2011


Am 15.07.2011 21:28, schrieb Antoine Pitrou:
> On Fri, 15 Jul 2011 20:26:42 +0200
> Georg Brandl <g.brandl at gmx.net> wrote:
>> 
>> Sorry, I don't see the immense complication in
>> 
>>         try:
>>             line = readline()
>>         except StopIteration:
>>             line = ''
>> 
>> Of course, if the tokenize API was designed from scratch nowadays,
>> it would probably only accept iterables, and you'd have to make one
>> yourself from a file object using
>> 
>>     iter(fd.readline, '')
> 
> Or, since file objects are iterable out of the box, you could simply
> pass the file object.

Yeah, that was a bad example :)  What I wanted to show is that it's
a one-liner to make an iterator out of a readline-type function, even
if you have only that.

Georg




More information about the Python-ideas mailing list