Copy construction of class instance object
Bror Johansson
bjohan at telia.com
Tue May 27 16:30:00 EDT 2003
More information about the Python-list mailing list
Tue May 27 16:30:00 EDT 2003
- Previous message (by thread): Copy construction of class instance object
- Next message (by thread): Copy construction of class instance object
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
"Peter Hansen" <peter at engcorp.com> wrote in message news:3ED3C1DE.8EC82FC2 at engcorp.com... > Bror Johansson wrote: > > > > Is there a good/recommended way to emulate the copy constructor > > classinstance creation (a la C++) in Python? > > "import copy" plus an appropriate line or two? See > http://www.python.org/doc/2.0/lib/module-copy.html My try: import copy class A(object): def __init__(self, ainst): self.val = 5 class B(A): def __init__(self, ainst): self = copy.deepcopy(ainst) a = A() b= B(a) print b.val => AttributeError: 'B' object has no attribute 'val'
- Previous message (by thread): Copy construction of class instance object
- Next message (by thread): Copy construction of class instance object
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list