:\codepy - raise 'spamtypeerrorexceptions must be old-style classes or derived from baseexceptionetc although you can' use string exceptions todaythey actually provide natural vehicle for introducing the class-based exceptions model class-based exceptions strings were simple way to define exceptions as described earlierhoweverclasses have some added advantages that merit quick look most prominentlythey allow us to identify exception categories that are more flexible to use and maintain than simple strings moreoverclasses naturally allow for attached exception details and support inheritance because they are seen by many as the better approachthey are now required coding details asidethe chief difference between string and class exceptions has to do with the way that exceptions raised are matched against except clauses in try statementsstring exceptions were matched by simple object identitythe raised exception was matched to except clauses by python' is test class exceptions are matched by superclass relationshipsthe raised exception matches an except clause if that except clause names the exception instance' class or any superclass of it that iswhen try statement' except clause lists superclassit catches instances of that superclassas well as instances of all its subclasses lower in the class tree the net effect is that class exceptions naturally support the construction of exception hierarchiessuperclasses become category namesand subclasses become specific kinds of exceptions within category by naming general exception superclassan except clause can catch an entire category of exceptions--any more specific subclass will match string exceptions had no such conceptbecause they were matched by simple object identitythere was no direct way to organize exceptions into more flexible categories or groups the net result was that exception handlers were coupled with exception sets in way that made changes difficult in addition to this category ideaclass-based exceptions better support exception state information (attached to instancesand allow exceptions to participate in inheritance hierarchies (to obtain common behaviorsbecause they offer all the benefits of classes and oop in generalthey provide more powerful alternative to the now-defunct string-based exceptions model in exchange for small amount of additional code exceptionsback to the future