On Sun, May 31, 2009 at 5:35 PM, Michael H. Goldwasser <[email protected]> wrote: > > Yesterday, I posted a question to python-list involving custom > deepcopies in an inheritance hierarchy. I haven't received any > responses, so I thought I'd cross-post to see if anyone on tutor > has any thoughts. > > To avoid splitting the thread, I'll simply reference the original post at > http://mail.python.org/pipermail/python-list/2009-May/714866.html > and ask for responses to be sent there.
Sorry, splitting the thread for you... ISTM that in general B.__deepcopy__() should call A.__deepcopy__() to do the "A" part of the work. In your example, this won't work because A.__deepcopy__() assumes that subclasses have a one-argument constructor. So, I would say that B is not fulfilling the contract assumed by A. What if you give B a one-arg constructor by making the bTag argument optional? Then I think B.__deepcopy__() can call A.__deepcopy__(), then do the "B" part of the copy on the result. Kent _______________________________________________ Tutor maillist - [email protected] http://mail.python.org/mailman/listinfo/tutor
