On Feb 3, 2:03 am, [EMAIL PROTECTED] wrote:
> Ruby has a neat little convenience when writing loops where you don't
> care about the loop index: you just do n.times do { ... some
> code ... } where n is an integer representing how many times you want
> to execute "some code."
>
> In Python, the direct translation of this is a for loop. When the
> index doesn't matter to me, I tend to write it as:
>
> for _ in xrange (1,n):
> some code
[...]
If 'some code' is a function (say f) you can write (with repeat from
itertools):
for action in repeat(f, n): action()
I don't know how 'Pythonic' this would be...
--
Arnaud
--
http://mail.python.org/mailman/listinfo/python-list