PEP 276 Simple Iterator for ints

Gareth McCaughan Gareth.McCaughan at pobox.com
Wed Nov 14 10:14:08 CET 2001


James_Althoff at i2.com wrote:
> Below is the first draft of PEP 276 "Simple Iterator for ints".
> (Available at http://python.sourceforge.net/peps/pep-0276.html)
> 
> Feel free to comment (positive, negative, bipolar, or in between ;-).

[SNIP: James proposes that e.g. 5.iter() should be roughly
equivalent to xrange(5), so that you can say "for x in 5: stuff".]

-0.7. Here's why.

  - It's deeply unintuitive and apparently arbitrary.
    And I speak as a mathematician with quite a lot of
    set theory in my background, so I'm used to a world
    in which 5 really *does* equal {0,1,2,3,4}. If every
    Python user were a set theorist, it might make more
    sense.

  - I'm decidedly unexcited about the major difference
    between "for x in 5:" and "for x in 5,:", both of
    which would be valid if the PEP took effect.

  - I agree that Python needs a better way of doing
    simple iterations over sequences of numbers. I'm
    concerned that if this PEP is accepted then it may
    discourage the implementation of something clearer.

  - For all that, the proposal *is* quite elegant, and
    the syntax it offers is certainly concise. And if
    numbers are going to provide iterators, James has
    chosen the right ones.

Well-written PEP, though.

-- 
Gareth McCaughan  Gareth.McCaughan at pobox.com
.sig under construc



More information about the Python-list mailing list