On 2020-12-31 21:34, Steven D'Aprano wrote:
Is there something we can do to make it easier for people to deal with recursive data structures, like the list repr and deepcopy code does? Is there a pattern we can abstract out and provide as a tool or recipe for people to use in their own code?
It sounds promising but so far a bit too vague for me to understand what you're really suggesting. What form would this "something" take? Are you envisioning, say, a function safe_recursive_iter so that you could do `for item in safe_recursive_iter(obj)` and it would cleanly raise an exception if it wound up recursing through the same object more than once, rather than getting stuck in an infinite loop? -- Brendan Barnwell "Do not follow where the path may lead. Go, instead, where there is no path, and leave a trail." --author unknown