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

Guido van Rossum guido at python.org
Sun Jan 7 12:25:44 EST 2018


On Sun, Jan 7, 2018 at 9:09 AM, Eric V. Smith <eric at trueblade.com> wrote:

On 1/3/2018 1:17 PM, Eric V. Smith wrote:

I’ll open an issue after I have time to read this thread and comment on it.

https://bugs.python.org/issue32513 I need to think though how eq and ne work, as well as the ordering operators. My specific concern with ne is that there's one flag to control their generation, but python will use "not eq" if you don't provide ne. I need to think through what happens if the user only provides eq: does dataclasses do nothing, does it add ne, and how does this interact with a base class that does provide ne.

Maybe dataclasses should only ever provide eq and always assume Python's default for ne kicks in? If that's not acceptable (maybe there are cases where a user did write an explicit ne that needs to be overridden) I would recommend the following rule:

-- --Guido van Rossum (python.org/~guido) -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20180107/fd904cca/attachment.html>



More information about the Python-Dev mailing list