replace
Return a new object replacing specified fields with new values.
This is especially useful for immutable objects, like named tuples or frozen dataclasses.
def replace(
obj: object,
**changes: dict
) - > object
Return a new object replacing specified fields with new values. This is especially useful for immutable objects, like named tuples or frozen dataclasses.
Parameters
| Name | Type | Description |
|---|---|---|
| obj | object | The object instance to be copied and modified. |
| **changes | dict | Keyword arguments representing the field names and their corresponding new values to be updated in the new object. |
Returns
| Type | Description |
|---|---|
object | A new instance of the same class with the updated field values applied. |