iters on ints? (reducing the need for range/xrange)
Steven D. Majewski
sdm7g at Virginia.EDU
Fri Nov 9 10:48:19 EST 2001
On Thu, 8 Nov 2001 James_Althoff at i2.com wrote:
> On the other hand, 2.2 takes us away from the concept of "suggesting a
> sequence" in the context of for-loops. Instead, the new for-loops are
> *iterator*-protocol based (not *sequence*-protocol based). They iterate
> over something that *is* or *can return* an iterator object.
>
> So under the proposed scenario, if one looks at 10 and asks "if 10 were to
> return an iterator, what would that iterator iterate over?", then it seems
> that range(10) would be a more *useful* answer than a sequence of one
> element 10.
>
I wouldn't be against 'iter(10)' returning an iterator but having 10 BE
an iterator is too much of a surprise.
Besides:
for i in 10:
is just too close to:
for i in 10,:
What would a newbie guess:
for i in 1,10:
means?
( I like 'for i in 1..10:' better. )
-- Steve
More information about the Python-list
mailing list