What are the best practices for creating exceptions? I just saw this, and I don\'t know if I should be horrified, or like it. I read several times in books that exceptions shoul
I believe the advice against creating exceptions with a string comes from "Learning Python" (O'Reilly). In a section entitled String Exceptions Are Right Out!, it points out the (now removed) ability to create an exception directly with an arbitrary string.
The code it gives as an example is:
myexc = "My exception string"
try:
raise myexc
except myexc:
print ('caught')
This is on p858 of the Fourth Edition (paperback).