> On Dec 29, 2017, at 4:52 PM, Guido van Rossum <[email protected]> wrote:
>
> I still think it should overrides anything that's just inherited but nothing
> that's defined in the class being decorated.
This has the virtue of being easy to explain, and it will help with debugging
by honoring the code proximate to the decorator :-)
For what it is worth, the functools.total_ordering class decorator does
something similar -- though not exactly the same. A root comparison method is
considered user-specified if it is different than the default method provided
by object:
def total_ordering(cls):
"""Class decorator that fills in missing ordering methods"""
# Find user-defined comparisons (not those inherited from object).
roots = {op for op in _convert if getattr(cls, op, None) is not
getattr(object, op, None)}
...
The @dataclass decorator has a much broader mandate and we have almost no
experience with it, so it is hard to know what legitimate use cases will arise.
Raymond
_______________________________________________
Python-Dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com