A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2017-September/149409.html below:

[Python-Dev] PEP 557: Data Classes

[Python-Dev] PEP 557: Data Classes [Python-Dev] PEP 557: Data ClassesIvan Levkivskyi levkivskyi at gmail.com
Fri Sep 8 19:19:20 EDT 2017
On 9 September 2017 at 01:00, Guido van Rossum <guido at python.org> wrote:

> I think it would be useful to write 1-2 sentences about the problem with
> inheritance -- in that case you pretty much have to use a metaclass,
>
>
It is not the case now. I think __init_subclass__ has almost the same
possibilities as a decorator, it just updates an already created class and
can add some methods to it.
This is a more subtle question, these two for example would be equivalent:

from dataclass import Data, Frozen

class Point(Frozen, Data):
    x: int
    y: int

and

from dataclass import dataclass

@dataclass(frozen=True)
class Point:
    x: int
    y: int


But the problem with inheritance based pattern is that it cannot support
automatic addition of __slots__.
Also I think a decorator will be easier to maintain.
But on the other hand I think inheritance based scheme is a bit more
readable.

--
Ivan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20170909/83426716/attachment.html>
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4