I’m reviewing some old python code and came accross this ‘pattern’ frequently:
class Foo(object):
def __init__(self, other = None):
if other:
self.__dict__ = dict(other.__dict__)
Is this how a copy constructor is typically implemented in Python?
This is a way to copy all attributes from one object to another one. However note that:
__init__method may have any type (not the same type as the object being created).