I would prefer plain 'yield' to 'yield break' as a synonym for 'raise StopIteration'. But the raise stands out better visually as an exit point. The point about the raise not being explicitly caught is not valid since any generator could be used in the following code g = some_gen try: while True: process(g.next()) except StopIteration: whatever() where it is caught. Then under your proposal, there would be a catch without a throw ;-(. If there were a use case for empty generators, then iter() could be made to produce one, in analogy with int() returning 0, etc. But without a use case, 'iter()' is much more likely to be a bug and should be flagged as such. In the meanwhile, 'iter(())' is trivial to type. Terry Jan Reedy
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4