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-December/151502.html below:

[Python-Dev] Concerns about method overriding and subclassing with dataclasses

[Python-Dev] Concerns about method overriding and subclassing with dataclassesEthan Furman ethan at stoneleaf.us
Fri Dec 29 15:30:52 EST 2017
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~
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