|
From: Stefan v. d. W. <st...@su...> - 2006-02-23 10:46:35
|
On Wed, Feb 22, 2006 at 08:58:28PM -0700, Travis Oliphant wrote: > Here's an outline of what you need to do. This is, of course,=20 > untested.... For example, I don't really know what actImage is. >=20 > from numpy import ndarray, array >=20 > class Image(ndarray, actImage): > def __new__(subtype, *args) > act1 =3D actImage.__new__(actImage, *args) > actImage.__init__(act1, *args) > arr =3D array(act1.getArray(), 'd', copy=3DFalse) > self =3D arr.view(subtype) > # you might need to copy attributes from act1 over to self here.= .. > return self This is probably the right place to use super, i.e.: def __new__(subtype, *args): act1 =3D super(Image, subtype).__new__(subtype, *args) ... def __init__(self, *args): super(Image, self).__init__(*args) The attached script shows how multiple inheritance runs through different classes. St=E9fan |