Detecting recursion loops

Fuzzyman fuzzyman at gmail.com
Fri Dec 1 17:22:09 EST 2006


robert wrote:
> 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?
>

Could you not store a set/list of nodes/points already visited and do
an early return if they recur ?

Fuzzyman
http://www.voidspace.org.uk/python/index.shtml

> Robert




More information about the Python-list mailing list