2 comments

[ 157 ms ] story [ 178 ms ] thread
Always 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.
Seems 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.