PEP 284, Integer for-loops (code bash?)
Laura Creighton
lac at strakt.com
Fri Mar 8 08:33:54 EST 2002
David Eppstein writes:
> Your ints module is nice, and I think if it were in the standard library
> I'd be a lot less motivated to push PEP 284. But, the objection to it
> will be that it only creates closed intervals, where other Python
> objects create half-open ones and it would be nice to have a syntax that
> would allow any combination of open and closed interval endpoints.
I am not so certain of this. I think that only some people think that
it would be nice to have a syntax that would allow any combination
of open and closed interval endpoints. I don't. I think that it
would have been nice if when Guido was designing the language he
used Haskall's syntax for loops. But he didn't. And I think that
the reason that no changes along these lines have happened despite
years of effort on the part of people who want changes is that this
is too hard a thing to retrofit a language with. There are no
changes that I can see that are not inferior to living with things
the way they are. They flunk my personal elegance test. Right now
I don't believe that it is possible to come around with one that is
elegant enough that I would support, because I think that we would
have found it already if it existed.
(Now watch Guido pass the PEP tomorrow :-) )
Laura Creighton
By the way, for your students, what keeps you from doing this:
import sys
_indices = xrange(sys.maxint)
#a reusable index sequence, use with zip only, NOT with map
...
for index, value in zip(_indices, someList):
whatever_you_want()
I am assuming that your problem is that you want to teach algorithms to
your students and you don't want their brains getting derailed with
'what is a range function' and 'what is an open-interval' and the like.
zip is rather easy to understand. Only the name is odd, but then map
is already taken. But perhaps I have misunderstood your problem.
Laura Creighton
More information about the Python-list
mailing list