New submission from Rémi Lapeyre <remi.lape...@henki.fr>: 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. ---------- messages: 333409 nosy: remi.lapeyre priority: normal severity: normal status: open title: Make dataclasses.field() accept another name for __init__ field's name versions: Python 3.8 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue35710> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com