A RetroSearch Logo

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

Search Query:

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

[Python-Dev] iter alternate form and *args and **kwargs (Was: Wishlist: dowhile)

[Python-Dev] iter alternate form and *args and **kwargs (Was: Wishlist: dowhile)James Y Knight foom at fuhm.net
Thu Jun 16 17:43:34 CEST 2005
On Jun 16, 2005, at 10:50 AM, Steven Bethard wrote:

> On 6/15/05, Benji York <benji at benjiyork.com> 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.  Look at
> unittest.TestCase.assertRaises to see another example of the kind of
> API I think should be supported (when possible, of course).

I think it's really the other way around. Forcing every API that  
takes a callable to also take a *args, **kwargs is a workaround for  
not having partial.

James
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