Python can't catch overridden NameError
问题 How can you explain this: This code is supposed to override the NameError and then catch it. OldNameError = NameError class NameError(OldNameError): pass try: ccc except NameError as e: print "hi" Does not print "hi". Instead, the output is: Traceback (most recent call last): File "try.py", line 6, in <module> ccc NameError: name 'ccc' is not defined But this code: OldNameError = NameError class NameError(OldNameError): pass try: raise NameError("oo") except NameError: print "hi" Gives the