Steven Bethard wrote:
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
I don't know - aren't they identical? I would write self.__class__ (without claiming that that's better)

BTW, I had a different question about the method:

wouldn't:
    result = self.__class__.__new__()
or in your form:
    result = type(self).__new__()

be better (i.e., clearer and possibly safer) than calling __init__ twice (but I haven't tried it!)

Michael



--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to