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/2003-November/040007.html below:

[Python-Dev] Re: PEP 322: Reverse Iteration

[Python-Dev] Re: PEP 322: Reverse Iteration [Python-Dev] Re: PEP 322: Reverse IterationGuido van Rossum guido at python.org
Wed Nov 5 10:28:01 EST 2003
> Why not change enumerate() to return an iterable, rather than an
> iterator?  Then its __reversed__ method could attempt to delegate to
> the underlying iterable.  Is it likely that anyone relies on
> enumerate() being an iterator, rather than an iterable?

I find it rather elegant to use enumerate() on a file to generate line
numbers and lines together (adding 1 to the index to produce a more
conventional line number).  What's more elegant than

  for i, line in enumerate(f):
      print i+1, line,

to print a file with line numbers???  I've used this in throwaway
code at least, and would hate to lose it.

--Guido van Rossum (home page: http://www.python.org/~guido/)

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