effectivepython
effectivepython copied to clipboard
Item #20: Extra "as e" in except statement
Page 82, Item 20, line 11 from top
try:
return a / b
except ZeroDivisionError as e:
raise ValueError('Invalid inputs')
The "as e" isn't necessary anymore because of the chaining automatically enabled by __cause__
and __context__
:
https://docs.python.org/3/library/exceptions.html