Join Nostr
2026-05-10 17:46:02 UTC
in reply to

Trey Hunner 🐍 on Nostr: Well, recursion is best for trees. 🌳 It's great for traversing or constructing a ...

Well, recursion is best for trees. 🌳

It's great for traversing or constructing a TREE-LIKE STRUCTURE: a file system, arbitrarily nested dictionaries, JSON/YAML/TOML, an abstract syntax tree, etc.

This function walks a dict-of-dicts of unknown depth: https://pym.dev/p/249np/

Writing this WITHOUT recursion is possible, but painful.

If you're NOT working with a tree-like structure, there's probably a clean iterative solution hiding in your problem.

More: https://pym.dev/what-is-recursion/

🧵 (6/6)