MCPcopy Index your code
hub / github.com/RustPython/RustPython / replace

Function replace

Lib/copy.py:276–286  ·  view source on GitHub ↗

Return a new object replacing specified fields with new values. This is especially useful for immutable objects, like named tuples or frozen dataclasses.

(obj, /, **changes)

Source from the content-addressed store, hash-verified

274
275
276def replace(obj, /, **changes):
277 """Return a new object replacing specified fields with new values.
278
279 This is especially useful for immutable objects, like named tuples or
280 frozen dataclasses.
281 """
282 cls = obj.__class__
283 func = getattr(cls, '__replace__', None)
284 if func is None:
285 raise TypeError(f"replace() does not support {cls.__name__} objects")
286 return func(obj, **changes)

Callers 13

flushMethod · 0.50
insertMethod · 0.50
stack_popMethod · 0.50
nextMethod · 0.50
dropMethod · 0.50
fstring_to_objectFunction · 0.50
tstring_to_objectFunction · 0.50
clearMethod · 0.50
set___qualname__Method · 0.50
set___name__Method · 0.50
set_exceptionMethod · 0.50

Calls 2

getattrFunction · 0.85
funcFunction · 0.50

Tested by

no test coverage detected