Liam Clarke <cyresse <at> gmail.com> writes: > Are there any other pitfalls with recursion I need to watch for?
Not just infinite recursion, but recursion that exceeds the maximum recursion depth (1000 on my system). You can add a counter parameter to your recursive function and stop recursing if the function finds it has called itself too many times - helps against infinite recursion too. >>> def a(i): ... i += 1 ... if i < 500: ... a(i) >>> a(0) If you try the function above without the if condition, it will generate a RuntimeError. Yours, Andrei _______________________________________________ Tutor maillist - [email protected] http://mail.python.org/mailman/listinfo/tutor
