MCPcopy
hub / github.com/faif/python-patterns / clone

Method clone

patterns/creational/prototype.py:34–40  ·  view source on GitHub ↗

Clone a prototype and update inner attributes dictionary

(self, **attrs: Any)

Source from the content-addressed store, hash-verified

32 self.__dict__.update(attrs)
33
34 def clone(self, **attrs: Any) -> Prototype:
35 """Clone a prototype and update inner attributes dictionary"""
36 # Python in Practice, Mark Summerfield
37 # copy.deepcopy can be used instead of next line.
38 obj = self.__class__(**self.__dict__)
39 obj.__dict__.update(attrs)
40 return obj
41
42
43class PrototypeDispatcher:

Calls 1

updateMethod · 0.45