Nicolas Vigier wrote:
> 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:
How should it behave with tuples or subclasses of List ? Or if it's any
other iterable ?
Testing against
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
Nicolas Vigier wrote:
> 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,
>
Nicolas Vigier wrote:
> 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,
>