Steven Bethard <[EMAIL PROTECTED]> writes:

> On 6/15/05, Benji York <[EMAIL PROTECTED]> wrote:
>> Steven Bethard wrote:
>> > I would prefer that the alternate iter() form was broken off into
>> > another separate function, say, iterfunc(), that would let me write
>> > Jp's solution something like:
>> >
>> > for chunk in iterfunc('', f1.read, CHUNK_SIZE):
>> >     f2.write(chunk)
>> 
>> How about 2.5's "partial":
>> 
>> for chunk in iter(partial(f1.read, CHUNK_SIZE), ''):
>>     f2.write(chunk)
>
> Yeah, there are a number of workarounds.  Using partial, def-ing a
> function, or using a lambda will all work.  My point was that, with
> the right API, these workarounds wouldn't be necessary. 

Well, I dunno.  I can see where you're coming from, but I think you
could make the argument that the form using partial is clearer to read
-- it's not absolutely clear that the CHUNK_SIZE argument is intended
to be passed to f1.read.  Also, the partial approach works better when
there is more than one callable.

Cheers,
mwh

-- 
  Like most people, I don't always agree with the BDFL (especially
  when he wants to change things I've just written about in very 
  large books), ... 
         -- Mark Lutz, http://python.oreilly.com/news/python_0501.html
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to