newbie: copy base class fields
Jerry Hill
malaclypse2 at gmail.com
Thu May 3 10:57:41 EDT 2007
On 3 May 2007 07:14:04 -0700, tmp123 <tmp123 at menta.net> wrote:
> Of course, it is not an option to copy one by one all the fields of
> class A inside the __init__ of B.
Is it okay to copy them all at once? Like this:
class B(A):
def __init__(self, a):
self.__dict__.update(a.__dict__)
self.v2 = 2
That will copy all of the attributes of instance a into the new instance.
--
Jerry
More information about the Python-list
mailing list