When creating a class, I sometimes wish to get this behavior:
def MyClass:
def __init__(self, param):
self._param = param
def __repr__(self):
return f"MyClass(param={self._param})"
Unless I'm making a mistaking, this behavior is not currently possible with dataclasses.
I propose to change:
field(*, default=MISSING, default_factory=MISSING, repr=True, hash=None, init=True, compare=True, metadata=None)
to:
field(*, default=MISSING, default_factory=MISSING, repr=True, hash=None, init=True, compare=True, metadata=None, target=None)
with target being used as the init parameter name for this field and in the repr.
If this is accepted, I can post the patch to make this change. |