4 ms·
Indeed although generally it's usually a bad idea to misappropriate the exception throwing / handling mechanism for other purposes, as it's probably be less wel
by harryf 9y ago
Indeed although generally it's usually a bad idea to misappropriate the exception throwing / handling mechanism for other purposes, as it's probably be less well optimised, performance-wise, than other parts of a VM.
- throwaway110116 9y agonot in python. exceptions for flow control are not looked down upon unless it’s gratuitous usage. many frameworks do exactly this.
- icebraining 9y agoEven the language itself does this: if a generator that is being processed by a for loop returns (rather than yield), the language will raise a StopIteration exception, which the for loop with catch and use as a signal that it should exit.
- oneweekwonder 9y agoYes! the more I dive into general py libraries the more I see `try: import pylib2 except: pylib2 = None` etc,