[Numpy-discussion] copy object with multiple subfields, including ndarrays

Timothy Hochberg tim.hochberg at ieee.org
Sun May 13 14:41:53 EDT 2007


It's alwys helpful if you can include a self contained example so it's easy
to figure out exactly what you are getting at. I say that because I'm not
entirely sure of the context here -- it appears that this is not numpy
related issue at all, but rather a general python question. If so, I think
what you are looking for is copy.deepcopy. As it name implies it does a deep
copy of an object as opposed to a shallow copy, which is what
copy.copydoes. If that doesn't do what you want or I misunderstood
your question,
please supply some more detail.


On 5/13/07, dmitrey <openopt at ukr.net> wrote:
>
> hi all,
> does anyone know howto copy an instance of class, that contains multiple
> subfields, for example
> myObj.field1.subfield2 = 'asdf'
> myObj.field4.subfield8 = numpy.mat('1 2 3; 4 5 6')
>
> I tried
> from copy import copy
> myObjCopy = copy(myObj)
> but it seems that it doesn't work correctly
>
> Thx, D.
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion at scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion
>



-- 

//=][=\\

tim.hochberg at ieee.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20070513/bb6e4da7/attachment.html>


More information about the NumPy-Discussion mailing list