iters on ints? (reducing the need for range/xrange)

Rainer Deyke root at rainerdeyke.com
Thu Nov 8 17:39:08 EST 2001


<James_Althoff at i2.com> wrote in message
news:mailman.1005256814.9657.python-list at python.org...
>
> Now that the issue of transfinite cardinals has been fully resolved, isn't
> it time for yet another unpopular-and-non-pythonic suggestion?  I believe
> it is.
>
> What if (in post-2.2) Python the tp_iter slot in the int type was defined
> to return an xrange-like iterator such that one could do the following:
>
> for i in 10:
>     doSomething(i)

I like it.  I guess that just goes to show how non-Pythonic I am.

Seriously, I don't see how this is worse or less Pythonic than, say, 'for
line in file'.


--
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