Semi-newbie, rolling my own __deepcopy__
Steven Bethard
steven.bethard at gmail.com
Mon Apr 4 14:30:41 EDT 2005
Michael Spencer wrote:
> def __deepcopy__(self, memo={}):
> from copy import deepcopy
> result = self.__class__()
> memo[id(self)] = result
> result.__init__(deepcopy(tuple(self), memo))
> return result
I know this is not your recipe, but is there any reason to use
self.__class__()
instead of
type(self)()
if you know you're inside a new-style class?
STeVe
More information about the Python-list
mailing list