> I am quite new to Python, and have a straight & simple question.
> In C, there is for (init; cond; advance). We all know that.
> In Python there are two ways to loop over i=A..B (numerical.):
> 1) i = A
>    while i<B:
>       ...do something...
>       i+=STEP

This is indeed quite ugly. You rarely need such loops in Python and
with some thinking you can often translate the C-equivalent to
something more pythonic. As you guessed, your second problem is best
solved with a generator function - xrange(). It is completely equal to
range() except that it returns a generator instead of a list.


-- 
mvh Björn
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to