On Sun, Aug 23, 2020 at 11:19 AM Gustav O firstname.lastname@example.org wrote:
In your answer, it sounds like the code would be written by the person developing a program. Or they could possibly have the importhook a separate module, which can be imported whenever you’d like to have it.
Maybe I misunderstood you, but this wouldn’t really be optimal. I think most people would like to get the part about shadowing imports without having to write any code or import a module that sends such error messages if a module might be shadowed. That removes the convenience of having something like that be a standard feature of the language itself.
Initially, it would be something you could add to sitecustomize.py, making it immediately available.
Would it be possible to make the exceptionhook a standard part of python, so it’s there by default?
Yes, it would. That would be a fully-debated proposal, but it is certainly possible for this sort of thing to be added to the core language. But if it's done as an excepthook, then even before that, it can be added by any sysadmin or any individual programmer.