Status of PEP's?

James_Althoff at i2.com James_Althoff at i2.com
Mon Mar 4 16:02:49 EST 2002


[Jeff Hinrichs]
> What you are asking everyone to agree with is:
>         5 = [0,1,2,3,4]

[Carel Fellinger]
> No he isn't:)  He explicitly says he doesn't think of
> sequences at all.

Exactly!

Rest assured that PEP 276 does *NOT* in any way call for 5 to be an
alternate spelling for the list [0,1,2,3,4].  It calls for class int to
define an __iter__ method that returns an iterator object whereby that
iterator object would produce (for the case of integer 5) the numbers
0,1,2,3,4 in turn.

Just to reinforce the point of the minimalist approach of PEP 276:

--  PEP 276 calls for *ZERO* (None, nill, nada) new syntax for Python.

--  PEP 276 basically amounts to adding to the int class a method similar
to the following:

    def __iter__(self):
        i = 0
        while i < self:
            yield i
            i += 1
        raise StopIteration

That's it.


[Jeff Hinrichs]
> If you were to restate the above as:
>        f(5)=[0,1,2,3,4]
> Then, I believe, that you wouldn't have any problem convincing a large
> majority that it is possible for f() to produce such an output.  That
being

[Carel Fellinger]
> And this is precisly what he's proposing, f is called iter in his
> case.  He comes from the camp that sees everything as an object, so
> numbers are objects to.  Hence integers know to do things, like
> adding, subtracting, and ... counting!  Three knows how to count from
> zero upto but not including three.  If you accept this, then the
> discussion is not whether integers are sequences, but whether it's
> natural to stretch Python's `for' construct to mean `count' or `over
> its preceding numbers' in case of an integer.  Like the `for'
> construct recently got stretched to mean `over all lines' and `over
> its keys' for text-files and dictionaries.  Admitted in those cases it
> still was a clear `iterate over', but the what was debatable.

Right.  The builtin function iter would work on integers.  For example,
iter(5) would return an iterator object that would iterate over 0,1,2,3,4.

Jim






More information about the Python-list mailing list