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

get_value()

Clone the default value for each instance.

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

Clone the default value for each instance.

Examples using tpcp.CloneFactory#

Dataclasses support

Dataclasses support

Dataclasses support