freegsnke.copying module

freegsnke.copying.copy_into(obj, new_obj, attr: str, *, mutable=False, strict=True, allow_deepcopy=False)[source]

Copies an attribute from one object to another.

Parameters:
  • obj (object) – The object to copy the attribute from

  • new_obj (object) – The object to copy the attribute to

  • attr (str) – The attribute name to copy (e.g. copy obj.attr into new_obj)

  • mutable (bool) – If an attribute is mutable it needs to be copied explicitly between objects, a reference is not sufficient.

  • strict (bool) – Raise an error if True and attr is not an attribute of obj

  • allow_deepcopy (bool) – Raise an error if True and a deepcopy is required to copy the attribute across.