[Python-ideas] iter() on steroids

Chris Rebert cvrebert at gmail.com
Fri Apr 13 07:16:15 CEST 2007


George Sakkis wrote:
> I proposed an (admittedly more controversial) version of this a few
> months back at the py3k list and the reaction was unexpectedly (IMO)
> negative or indifferent, so I'm wondering if things have changed a bit
> since.
> 
> The proposal is to make the the builtin iter() return an object with
> an API that consists of (most) functions currently at itertools. In
> addition to saving one "from itertools import chain,islice,..." line
> in every other module I write these days, an extra bonus of the OO
> interface is that islice can be replaced with slice syntax and chain
> with '+' (and/or perhaps the "pipe" character '|'). As a (deliberately
> involved) example, consider this:
[snipped]
> Comments ?

+0 on your proposal
I just don't see itertools being used often enough to justify your 
change, but I can see the utility for those instances where it is used 
heavily.

+1 on adding your Iter class (or something similar) to itertools
Less controversial and just as succinct/convenient as your proposal 
(Iter() vs iter()), save another line for the requisite import.

- Chris Rebert



More information about the Python-ideas mailing list