23 Aug
2020
23 Aug
'20
12:59 a.m.
It seems like most of us agree that the speed drawbacks wouldn’t be worth it — which I find understandable. If my understanding of excepthooks is correct, and that it’s the place to put code that should be executed once an AttributeError is raised, it sounds like a great solution. However, AttributeErrors aren’t the only exceptions raised when a shadowing module is imported. A broad range of exceptions could be raised as a result of an unintended module being imported. One option would be to implement a similar search whenever any exception is raised and the conditions that you mentioned apply. Limiting it to AttributeError would be odd. -- Gustav