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

Steven Bethard steven.bethard at gmail.com
Thu Jun 16 16:50:42 CEST 2005


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).

Steve
-- 
You can wordify anything if you just verb it.
        --- Bucky Katt, Get Fuzzy


More information about the Python-Dev mailing list