Re:Python 2.x vs. 3.x use survey
by maxerickson on Wednesday December 10, 2014 @02:05PM
(#8730979)
It's the other way around, they are not removed, the default implementations are now lazy. So in python 3 you get an interator:
and have to explicitly construct a list:
[ Parent
| on HN ]
Re:Python 2.x vs. 3.x use survey
by merlincorey on Wednesday December 10, 2014 @02:43PM
(#8731231)
Ah, I actually like that!
That is indeed cleaner. Thanks for the explanation.
Re:Python 2.x vs. 3.x use survey
by agentultra on Wednesday December 10, 2014 @03:20PM
(#8731429)
Traversing 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.