from dataclasses import dataclass
from utils import gen_x
@dataclass
class Data:
x: str
def foo():
self.x = gen_x()
d = Data('bar')
d.foo()
I need to modify x in place from usability reasons, but I don’t know how to clearly indicate that in name of method which performs that modification (named here: foo).
Rejected names:
- generate_x – means, that x is generated and returned, not substituted in instance
- substitute_x – better than previous, but looks strange
>Solution :
update_x or replace_x – These two names would be better if you want to modify the x attribute in place