31 May
2018
31 May
'18
6 p.m.
On Thu, May 31, 2018 at 10:37 AM Nick Coghlan
The exception machinery deliberately attempts to avoid instantiating
exception objects whenever it can, but that gets significantly more difficult if we always need to create the instance before we can decide whether or not the raised exception matches the given exception handler criteria. Is this really true? Consider the following simple code class E(Exception): def __init__(self): print("instantiated") try: raise E except E: pass Is it truly necessary to instantiate E() in this case? Yet when I run it, I see "instantiated" printed on the console.