This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author remi.lapeyre
Recipients remi.lapeyre
Date 2019-01-10.17:11:11
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1547140271.38.0.846532339527.issue35710@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2019-01-10 17:11:13remi.lapeyresetrecipients: + remi.lapeyre
2019-01-10 17:11:11remi.lapeyresetmessageid: <1547140271.38.0.846532339527.issue35710@roundup.psfhosted.org>
2019-01-10 17:11:11remi.lapeyrelinkissue35710 messages
2019-01-10 17:11:11remi.lapeyrecreate