class 'Exception', unable to use 'super' to call superclass initializer
chriss at streiff.org
Sat Sep 10 23:53:39 CEST 2005
Peter Hansen wrote:
> chriss wrote:
>> environment: Python 2.4, GNU/Linux, kernel 220.127.116.11
>> having subclassed 'Exception' I'm trying to call the initialiser
>> __init__(...) of the superclass Exception with 'super(..).__init__(..)' .
>> However, trying to do so results in a
>> 'TypeError: super() argument 1 must be type, not classobj'.
>> Now, if I use 'Exception.__init__(..)' instad of super(..)... ,everything
>> works just as one would expect.
>> Why does 'super(..).__init__(..)' fail?
> Exceptions do not inherit from 'object'; they are old-style classes.
> super() can be used only with new-style classes (which subclass 'object').
That explains it all right.
Thank you very much for your answer.
More information about the Python-list