Initializing a subclass with a super object?
frankdmartinez at gmail.com
frankdmartinez at gmail.com
Mon May 12 09:16:20 EDT 2008
On May 11, 3:19 am, Francesco Bochicchio <bock... at virgilio.it> wrote:
> But there is not such a thing, in Python. What you have is that A
> has the same attributes/methods of B plus its own.
> What you could do is adding in class A a method like this:
>
> class A(B):
> ...
> def set_b_attributes(self, instance_of_b):
> for k, value in instance_of_b.__dict__:
> setattr(self, k, value )
>
> and the use it like this:
>
> a1.set_b_attributes(b1)
Hi, Francesco.
Thanx! That's actually exactly what I needed (though I didn't
know it).
More information about the Python-list
mailing list