tpcp.CloneFactory#

class tpcp.CloneFactory(default_value: T)[source]#

Init factory that creates a clone of the provided default values on instance initialisation.

This can be used to make sure that each instance get their own version own copy of a mutable default of a class init. Under the hood this uses clone.

Methods

__call__()

Call self as a function.

get_value()

Clone the default value for each instance.

__init__(default_value: T) None[source]#
get_value() T[source]#

Clone the default value for each instance.

Examples using tpcp.CloneFactory#

Dataclass and Attrs support

Dataclass and Attrs support