[Tutor] Looping

spir denis.spir at free.fr
Mon Apr 20 18:44:50 CEST 2009


Le Mon, 20 Apr 2009 17:26:30 +0200,
"A.T.Hofkamp" <a.t.hofkamp at tue.nl> s'exprima ainsi:

> 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 
> construct.
> What kind of function do you have that needs to be called 10 times?

Actually, it's even rare to have to run a func n times, where n is known at runtime only. Builtin iteration (for item in container) removes 99% (about ;-) of such needs.

Denis
------
la vita e estrany


More information about the Tutor mailing list