[Tutor] Looping

A.T.Hofkamp a.t.hofkamp at tue.nl
Mon Apr 20 17:26:30 CEST 2009

Matt wrote:
> Hey everyone,
> First post to this list. I hope I'm doing it right.
> Let's say I want to run func 10 times Is there a more pythonic way to do it than this:
> for i in xrange(10):
>  func()

no, that looks fine for your requirement.

What may be a bit weird here is the requirement to run the same function 10 
times without further input/output parameters. I have never needed such a 
What kind of function do you have that needs to be called 10 times?

If you are doing timing experiments, the timeit library has a way of repeating 
the same experiment a number of times.


More information about the Tutor mailing list