version skew notepython and later require exceptions to be defined by classes in addition requires exception classes to be derived from the baseexception built-in exception superclasseither directly or indirectly as we'll seemost programs inherit from this class' exception subclassto support catchall handlers for normal exception types--naming it in handler will thus catch everything most programs should python allows standalone classic classes to serve as exceptionstoobut it requires new-style classes to be derived from built-in exception classesthe same as exceptionsback to the future once upon time (wellprior to python and )it was possible to define exceptions in two different ways this complicated try statementsraise statementsand python in general todaythere is only one way to do it this is good thingit removes from the language substantial cruft accumulated for the sake of backward compatibility because the old way helps explain why exceptions are as they are todaythoughand because it' not really possible to completely erase the history of something that has been used by on the order of million people over the course of nearly two decadeslet' begin our exploration of the present with brief look at the past string exceptions are right outprior to python and it was possible to define exceptions with both class instances and string objects string-based exceptions began issuing deprecation warnings in and were removed in and so today you should use class-based exceptionsas shown in this book if you work with legacy codethoughyou might still come across string exceptions they might also appear in bookstutorialsand web resources written few years ago (which qualifies as an eternity in python years!string exceptions were straightforward to use--any string would doand they matched by object identitynot value (that isusing isnot ==) :\codec:\python \python myexc "my exception stringtryraise myexc except myexcprint('caught'caught were we ever this youngthis form of exception was removed because it was not as good as classes for larger programs and code maintenance in modern pythonsstring exceptions trigger exceptions insteadc:\codepy - raise 'spam exception objects