MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / clone

Method clone

tools/python-3.11.9-amd64/Lib/email/_policybase.py:60–76  ·  view source on GitHub ↗

Return a new instance with specified attributes changed. The new instance has the same attribute values as the current object, except for the changes passed in as keyword arguments.

(self, **kw)

Source from the content-addressed store, hash-verified

58 return "{}({})".format(self.__class__.__name__, ', '.join(args))
59
60 def clone(self, **kw):
61 """Return a new instance with specified attributes changed.
62
63 The new instance has the same attribute values as the current object,
64 except for the changes passed in as keyword arguments.
65
66 """
67 newpolicy = self.__class__.__new__(self.__class__)
68 for attr, value in self.__dict__.items():
69 object.__setattr__(newpolicy, attr, value)
70 for attr, value in kw.items():
71 if not hasattr(self, attr):
72 raise TypeError(
73 "{!r} is an invalid keyword argument for {}".format(
74 attr, self.__class__.__name__))
75 object.__setattr__(newpolicy, attr, value)
76 return newpolicy
77
78 def __setattr__(self, name, value):
79 if hasattr(self, name):

Callers 1

__add__Method · 0.95

Calls 4

__new__Method · 0.45
itemsMethod · 0.45
__setattr__Method · 0.45
formatMethod · 0.45

Tested by

no test coverage detected