recursive function call

2005-11-08 Thread Nicolas Vigier
Hello, I have in my python script a function that look like this : def my_function(arg1, arg2, opt1=0, opt2=1, opt3=42): if type(arg1) is ListType: for a in arg1: my_function(a, arg2, opt1=opt1, opt2=opt2, opt3=opt3) return

Re: recursive function call

2005-11-08 Thread Nicolas Vigier
Peter Otten said: Here is a non-recursive approach: def tolist(arg): if isinstance(arg, list): return arg return [arg] def f(arg1, arg2, more_args): for arg1 in tolist(arg1): for arg2 in tolist(arg2): # real code If it were my code I would omit the