3 ms·
not in python. exceptions for flow control are not looked down upon unless it’s gratuitous usage. many frameworks do exactly this.
by throwaway110116 9y ago
not 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,