New submission from Théophile Chevalier <theophile.cheval...@lenstra.fr>:

Calling dataclasses.replace(instance, **changes) returns a new object of the 
same type.

>From my understanding there is, however, no method to update in place fields 
>of a dataclass from another one.

I propose to add dataclasses.update(instance_to_update, other_instance, 
**changes).

This would for instance allow one to change all fields of current object in a 
sturdy way.
In my case, I currently call obj.__dict__.update(other_obj.__dict__) to perform 
the operation, but I know it has always to be done pretty carefully.

If this is accepted, I'm willing to post the change.

----------
messages: 333872
nosy: theophile
priority: normal
severity: normal
status: open
title: Allow dataclasses to be updated in place
type: enhancement
versions: Python 3.8

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue35761>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to