About generators

Andrea Griffini agriff at tin.it
Mon Apr 26 02:30:10 EDT 2004


I'm new to python and I really like what I've seen so far
with just one exception; the absence of a nice syntax
for ranges of integers. I've read PEPs about allowing

   for i in 10:
     print i

and I must say I don't like it very much, but I didn't
find a discussion about what looks more natural

   for i in 0...9:
     print i

or

   squares = [x*x for x in 1...100]

that is having "expr1 ... expr2" returning an iterator
from expr1 to expr2 (second limit included).

Has this been considered ? If yes (as I suppose) where
can I find and explanation about it ? So far python
seems very logical, and an explanation of this seemingly
illogical absence would help me (I hope) in better
understanding this language.

TIA
Andrea



More information about the Python-list mailing list