SoFunction
Updated on 2024-11-16

Differences and connections between python3 and python2 exception handling

In , exceptions are handled like this, with the exception base class followed by a comma " , " and then the exception type

import traceback

try:
  1/0
except Exception , err:
  print err
 

This is how exceptions are handled in the base class by linking the exception type with the keyword "as".

import traceback

try:
  1/0
except Exception as err:
  print(err)

That's all there is to this article, and I hope you enjoy it.