PEP 276 Simple Iterator for ints
Rainer Deyke
root at rainerdeyke.com
Wed Nov 14 12:27:08 EST 2001
"Skip Montanaro" <skip at pobox.com> wrote in message
news:mailman.1005730219.6744.python-list at python.org...
> Though after reading the remainder of the thread, I like the Haskell
syntax
> best.
One thing bothers me about the Haskell syntax: using it to generate
sequences of less than three elements just looks wrong.
[1, 2, ... 3] # This is obviously [1, 2, 3].
[1, 2, ... 2] # What is this? [1, 2]?
[1, 2, ... 1] # [1]?
[1, 2, ... 0] # []?
Another thing that bothers me is that I'm it's not obvious how the elements
are evaluated. This is not an issue in Haskell, but it is in Python:
def f(n):
print n
return n
for i in [f(0), f(1), ... f(5)]: pass
I assume that this prints 0, 1, and 5. That makes sense from one
perspective, but doesn't make sense at all from another perspective.
Another example:
for i in [g() + 0, g() + 1, ... g() + 13]: pass
How often is 'g' called? Once? 3 times? 14 times?
--
Rainer Deyke (root at rainerdeyke.com)
Shareware computer games - http://rainerdeyke.com
"In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor
More information about the Python-list
mailing list