by necovek · 5y ago · 0 comments
In Python, `for value in iterator: x(value)` is syntactic sugar for (roughly)
while True:
try:
value = next(iterator)
except IterationError:
break
x(value)
Basically, it seems that `while conditional` are both low-level control flow constructs in both: how do they differ between languages?Python's “for … in” is syntax sugar in the sense that is an abstraction over constantly writing out the iterator protocol.