- Using
__slots__ = ()
inside a class will prevent its attributes to be changed. [ref] - Only for Python3, 3 different types of raising Exception:
- Normal Exception (Not expected to have another exception while handling an exception)
try: raise Exception("Error") except Exception as e: raise Exception("Error while handling Exception")
- Cause of Exception (The second exception is expected to happen while handling an exception)
try: raise Exception("Error") except Exception as e: raise Exception("Different Exception") from e
- Only show last Exception (Ignoring the first exception)
try: raise Exception("Error") except Exception as e: raise Exception("Different error") from None
- Normal Exception (Not expected to have another exception while handling an exception)