my recursive function call is wrong?

2009-08-16 Thread Chang Min Jeon
I'm trying to write program to translate define macro in 'C'. And start_parse has return condition that list's length is 0. At this time return statement invoke start_parse() function. I can't understand do that. I'm using Python 2.6.2 in Windows XP import re import sys comment = ''' #if defined

Re: my recursive function call is wrong?

2009-08-16 Thread Kev Dwyer
On Sun, 16 Aug 2009 16:57:41 +0900, Chang Min Jeon wrote: Hello, You have placed recursive calls to the function in a number of different locations; when len(macro) becomes zero control will return to the calling function, but this calling function may have more code to execute, including

Re: my recursive function call is wrong?

2009-08-16 Thread Chang Min Jeon
Dear Kev Thank you very much. I got it.:) 2009/8/16 Kev Dwyer kevin.p.dw...@gmail.com On Sun, 16 Aug 2009 16:57:41 +0900, Chang Min Jeon wrote: Hello, You have placed recursive calls to the function in a number of different locations; when len(macro) becomes zero control will return to

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 Peter Otten
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,

Re: recursive function call

2005-11-08 Thread Duncan Booth
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,

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

Re: recursive function call

2005-11-08 Thread bruno at modulix
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 the