[Python-Dev] Concerns about method overriding and subclassing with dataclasses (original) (raw)

Ethan Smith ethan at ethanhs.me
Fri Dec 29 19:35:32 EST 2017


On Fri, Dec 29, 2017 at 12:30 PM, Ethan Furman <ethan at stoneleaf.us> wrote:

On 12/29/2017 11:55 AM, Ethan Smith wrote:

On Fri, Dec 29, 2017 at 11:37 AM, Ethan Furman wrote:

It is possible to determine whether an existing repr is from 'object'

>> or not, and only provide one if that is the case. I think that should be >> the default, with 'repr = True' for those cases where a new, auto-generated, repr is desired.

The only other thing you'd want to handle is to cover inheriting from another dataclass. e.g., if I have dataclass with attribute a, and subclass it to add attribute b, I'd want both in the repr. Good point. So auto-generate a new repr if: - one is not provided, and - existing repr is either: - object.repr, or - a previous dataclass repr And if the auto default doesn't work for one's use-case, use the keyword parameter to specify what you want. -- Ethan


Python-Dev mailing list Python-Dev at python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/ethan% 40ethanhs.me -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20171229/b53db091/attachment.html>



More information about the Python-Dev mailing list