A RetroSearch Logo

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

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2000-July/006967.html below:

[Python-Dev] PEP 201 - Parallel iteration

[Python-Dev] PEP 201 - Parallel iterationKa-Ping Yee ping@lfw.org
Wed, 19 Jul 2000 09:46:39 -0700 (PDT)
On Wed, 19 Jul 2000, Barry A. Warsaw wrote:
> 
> I've been thinking a little bit about the other generators, especially
> irange().  I wonder if we shouldn't just be putting zip() and friends
> in their own Python module and not make them builtins?

I'd say put both zip() and irange() in builtins.  They're useful enough.

(Ideally range(), zip(), and irange() would all make generators one day,
and xrange() could be deprecated.)

I would prefer zip() and irange() to make generators now -- because
this means you could *pass* them generators, and they wouldn't force
their arguments to enumerate everything first!

For example, make readlines() a generator too and you've got

    for lnum, line in irange(file.readlines()):
        print "%5d: %s" % (lnum, line),

How pretty is that?

There's no issue with using generators in place of lists, as far
as i can tell, since (as has already been suggested) you just turn
the generator into a real list if somebody calls one of the
methods on it or uses it where a tuple is expected.


-- ?!ng




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