[Tutor] exercise is recursion (more problems with my comp)

alan.gauld@bt.com alan.gauld@bt.com
Wed, 22 Nov 2000 11:33:48 -0000


> It's been a very long time since I wrote a program that used recursion
> (Hmmm...college...Pascal). I'd forgotten what a pain in the 
> butt it is to
> debug. Any hints?

To debug recursive routines I always put in an entry and exit 
print statement:

def recursingfunc(p1,p2):
    print "entering recursingfunc(%s,%s)" % (p1,p2)
    # ... so it here ...
    print "returning %s from recursingfunc" % retvalue

The trace from that is usually enough to show me where 
I've gone wrong.

Alan G.