4 ms·
Ah, I actually like that! That is indeed cleaner. Thanks for the explanation.
by merlincorey 12y ago
Ah, I actually like that!
That is indeed cleaner. Thanks for the explanation.
- agentultra 12y agoTraversing a binary tree without an explicit stack is also much cleaner thanks to sub-generators. if tree.left: yield from traverse(tree.left) yield tree if tree.right: yield from traverse(tree.right) As a trivial example.