[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 returned"] > ... print "printing result: " > ... print result > ... return result > ... > >>>>reTest(False) > > YAHHH > printing result: > ['should be the only thing returned'] > printing result: > [] > [] > > I don't understand why results are returned twice? is there something > special i missed about recursive functions? > The only thing you appear to have misunderstood is that there;s absolutely nothing special about recursive functions at all, and the Python interpreter is doing exactly what you told it to.
regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC www.holdenweb.com PyCon TX 2006 www.python.org/pycon/ -- http://mail.python.org/mailman/listinfo/python-list