3 ms·
Mastering Python's Yield: An Advanced Guide
- jstx1 3y agoAlways disliked the design of iterators in Python - you use 'def' but it's not a function, you call it like a function but it preserved its state - there should be a less confusing way to express these semantics than yield.
- redman25 3y agoSeems fine to me :shrug: as long as you know that using yield changes the ‘def’ to return a generator. It’s a bit of syntactic sugar but simple enough to follow.