Re: deepcopy does not work for A subclassed list



On 07/10/2011 20:29, txismis unzetabarrenetxeagoikolea wrote:
This is the issue

I have created a mylist class by subclassing a List, added several
attributes to mylIst , and overrided the append method which takes into
account one of the new attributes.

mylist class is functional and works as I planned, but when I try to
deepcopy objects from mylist I received errors because the attribute has
not been copied and the override append raise an error.

When I want to deepcopy one object from mylist the algorithm does not
take into account the attributes I created; ergo, I have some errors
from the copy module

I can use pickle to dump and load objects from my subclass with no errors.

Any ideas about how to make the copy module to behave as expected.

The documentation talks about defining a "__deepcopy__" method.
.



Relevant Pages

  • Re: the cobwebs are getting pretty thick
    ... Smalltalk implementations and anyone subclassing off of any of these ... Any time anyone has to override a behavior, it is because of the "beast" which we must avoid, or more often because deeper thought and better design would have served us in the Superclass. ...
    (comp.lang.smalltalk)
  • Re: A simple question for Abstract Class
    ... override the methods to be processed by your window in an anonymous ... other than an error for someone to use this class without subclassing it". ... This forces the programmer to make a conscious decision about methods ...
    (comp.lang.java.programmer)
  • Subclass a CRichEditCtrl, having trouble overriding OnNotify()
    ... I am subclassing a CRichEditCtrl, and I'm trying to override the ... and then call the SetEventMaskmember to enable notifications. ... In the subclass's header file I set up to override the OnNotify. ...
    (microsoft.public.vc.mfc)
  • Re: How do I modify existing Microsoft web parts?
    ... You can try subclassing the mention web part and override the RenderWebPart ... But I'm not sure how successful it will be. ... you could pass a StringWriter to the RenderWebPart() ...
    (microsoft.public.sharepoint.portalserver.development)