recursive function return value problems

2005-12-28 Thread randomtalk
hi, i have the following recursive function (simplified to demonstrate the problem): def reTest(bool): ... result = [] ... if not bool: ... reTest(True) ... else: ... print YAHHH ... result = [should be the only thing returned] ... print

Re: recursive function return value problems

2005-12-28 Thread Brian L. Troutwine
[EMAIL PROTECTED] wrote: def reTest(bool): ... result = [] ... if not bool: ... reTest(True) ... else: ... print YAHHH ... result = [should be the only thing returned] ... print printing result: ... print result ... return result ...

Re: recursive function return value problems

2005-12-28 Thread randomtalk
the final returned value is: [] the two values printed is (note i only have one print statement printing print result,. however, in the actualality, it's printed twice): printing result: ['should be the only thing returned'] printing result: [] therefore, sadly, i don't thinkg you've understand

Re: recursive function return value problems

2005-12-28 Thread Dan Sommers
On 28 Dec 2005 15:25:30 -0800, [EMAIL PROTECTED] wrote: hi, i have the following recursive function (simplified to demonstrate the problem): def reTest(bool): ... result = [] ... if not bool: ... reTest(True) Don't do that. Do this instead: result =

Re: recursive function return value problems

2005-12-28 Thread casevh
You have two calls to reTest and so reTest needs to return twice. One return is from the reTest(True) call back to reTest(False). The second return is from reTest(False) back to the prompt. What were you expecting to happen? -- http://mail.python.org/mailman/listinfo/python-list

Re: recursive function return value problems

2005-12-28 Thread Steven D'Aprano
On Wed, 28 Dec 2005 15:25:30 -0800, randomtalk wrote: hi, i have the following recursive function (simplified to demonstrate the problem): def reTest(bool): ... result = [] ... if not bool: ... reTest(True) ... else: ... print YAHHH ... result =

Re: recursive function return value problems

2005-12-28 Thread randomtalk
ah, result = reTest(True) works, thanks alot :D -- http://mail.python.org/mailman/listinfo/python-list

Re: recursive function return value problems

2005-12-28 Thread Steven D'Aprano
On Wed, 28 Dec 2005 16:05:30 -0800, randomtalk wrote: the final returned value is: [] the two values printed is (note i only have one print statement printing print result,. however, in the actualality, it's printed twice): printing result: ['should be the only thing returned'] printing

Re: recursive function return value problems

2005-12-28 Thread Martin v. Löwis
[EMAIL PROTECTED] wrote: ... if not bool: ... reTest(True) I don't understand why results are returned twice? is there something special i missed about recursive functions? Yes, although it is not clear *what* it is that you are missing. Here is my guess: you fail to see that

Re: recursive function return value problems

2005-12-28 Thread Mike Meyer
[EMAIL PROTECTED] writes: hi, i have the following recursive function (simplified to demonstrate the problem): def reTest(bool): ... result = [] ... if not bool: ... reTest(True) ... else: ... print YAHHH ... result = [should be the only thing returned]

Re: recursive function return value problems

2005-12-28 Thread Steve Holden
[EMAIL PROTECTED] wrote: hi, i have the following recursive function (simplified to demonstrate the problem): def reTest(bool): ... result = [] ... if not bool: ... reTest(True) ... else: ... print YAHHH ... result = [should be the only thing

Re: recursive function return value problems

2005-12-28 Thread bonono
[EMAIL PROTECTED] wrote: hi, i have the following recursive function (simplified to demonstrate the problem): def reTest(bool): ... result = [] ... if not bool: ... reTest(True) ... else: ... print YAHHH ... result = [should be the only thing