Detecting recursion loops
Bytter
bytter at gmail.com
Wed Nov 29 12:58:28 EST 2006
Hi!
I hope you are not trying to find infinite loops and I simply
misunderstood your question. Because if you are, then forget it (Turing
anyone?)... Infinite loops are impossible to find (minus some few, very
specific situations).
Cf. http://en.wikipedia.org/wiki/Halting_problem
Cheers,
Hugo Ferreira
P.S. Hmmm... It seems I really read it wrong since you define that you
want to stop "(after N passes or some complex criteria)". Anyway I
leave the warning for future generations :)
> My code does recursion loops through a couple of functions. Due to problematic I/O input this leads sometimes to "endless" recursions and after expensive I/O to the Python recursion exception.
> What would be a good method to detect recursion loops and stop it by user-Exception (after N passes or some complex criteria) without passing a recursion counter parameter through all the funcs?
>
> Robert
More information about the Python-list
mailing list