Calling a derived class's constructor from a parent method
Mark Lawrence
breamoreboy at yahoo.co.uk
Wed Jan 14 23:44:18 EST 2015
On 15/01/2015 00:40, Steven D'Aprano wrote:
> jason wrote:
>
>> class B(A):
>> def __init__(self, s):
>> A.__init__(self, s)
>
> Unrelated:
>
> It is better to call super than manually call the superclass. Calling A
> directly means your class is no longer compatible with multiple
> inheritance.
>
> def __init__(self, s):
> super(B, self).__init__(s)
>
For the OP an excellent article on super here
https://rhettinger.wordpress.com/2011/05/26/super-considered-super/
--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.
Mark Lawrence
More information about the Python-list
mailing list