|
|
Subscribe / Log in / New account

Exceptions

Exceptions

Posted Sep 1, 2022 11:49 UTC (Thu) by petrm (subscriber, #126046)
In reply to: Exceptions by pwfxq
Parent article: Python multi-level break and continue

You would think so, but Python has a built-in exception to signal that an iterator has nothing else to yield: https://docs.python.org/3/library/exceptions.html#StopIte...
Seems to me that the fact that an iterator has been fully drained is not exactly an unexpected event. That's bound to happen at some point. And yet, exception. (Because sure, how else are you going to signal this?) Using exceptions for multi-level loop exit seems rather similar to this use case.


to post comments


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds