Re: Initializing a subclass with a super object?
On May 11, 3:19 am, Francesco Bochicchio <[EMAIL PROTECTED]> 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). -- http://mail.python.org/mailman/listinfo/python-list
Re: Initializing a subclass with a super object?
Hi, Terry. Yeah, no. If we think of the inherited B as an object nested within a1, I'm attempting to initialize that B with b1 by accessing the B, say, via a function call. I don't see how using a python factory achieves this. -- http://mail.python.org/mailman/listinfo/python-list
Initializing a subclass with a super object?
Class A inherits from class B. Can anyone point me in the direction of documentation saying how to initialize an object of A, a1, with an object of B, b1? -- http://mail.python.org/mailman/listinfo/python-list