class Foo(object):

    def __init__(self, bar):
        self.bar = bar
self.spam = expression + that * generates - ham

def __copy__(self):
    return type(self)(self.bar)

def __deepcopy__(self, memo):
    pass
Python: Implementation of shallow and deep copy constructors