Re:Python Type Hints – How to Handle Optional Imports
by _aavaa_ on Wednesday January 05, 2022 @10:37AM
(#29810261)
It took me a few seconds to figure out what you were talking about with Pokemon. That's the first time I've heard that term! I love it.
(For anyone else scratching their head, it's Pokemon exception handling cause the except block catches any and all exceptions (gotta catch 'em all).)
The first import can fail for any number of reasons apart from the expected one and that reason will be swallowed and potentially replaced by a different, misleading, second order error message or worse - strange hard to explain behavior.
The second will behave (and more importantly, fail) in a much more predictable way.