int.__init__ incompatible in Python 3.3

Ulrich Eckhardt ulrich.eckhardt at dominolaser.com
Fri Nov 9 13:52:22 CET 2012


Am 09.11.2012 12:37, schrieb Steven D'Aprano:
> On Fri, 09 Nov 2012 08:56:22 +0100, Ulrich Eckhardt wrote:
>> Or, do you suggest I don't call super().__init__()? That would seem
>> unclean to me.
>
> On the contrary: calling super().__init__ when the superclass does
> something you don't want (i.e. raises an exception) is unclean.
>
> Since the superclass __init__ does nothing, you don't need to call it.
> Only inherit behaviour that you actually *want*.


That one's hard to swallow for me, but maybe this is because I don't 
understand the Python object model sufficiently. The problem I have here 
is that not forwarding the __init__() to the baseclass could mean that 
necessary initializations are not performed, although in this very 
specify case I see that there aren't any. It still seems a bit like 
relying on an implementation details.

Anyhow, I'll have to do some more reading on the the construction of 
objects in Python, maybe then it'll all make sense. Until then, thanks 
everybody for nudging me in the right direction!

Uli



More information about the Python-list mailing list