[Python-Dev] PEP 557: Data Classes

Paul Moore p.f.moore at gmail.com
Fri Sep 8 11:52:26 EDT 2017


On 8 September 2017 at 15:57, Eric V. Smith <eric at trueblade.com> wrote:
> I've written a PEP for what might be thought of as "mutable namedtuples with
> defaults, but not inheriting tuple's behavior" (a mouthful, but it sounded
> simpler when I first thought of it). It's heavily influenced by the attrs
> project. It uses PEP 526 type annotations to define fields.
[...]
> The PEP is largely complete, but could use some filling out in places.
> Comments welcome!
>
> Eric.
>
> P.S. I wrote this PEP when I was in my happy place.

Looks good! One minor point - apparently in your happy place, C and
Python have the same syntax :-)

"""
field's may optionally specify a default value, using normal Python syntax:

@dataclass
class C:
    int a       # 'a' has no default value
    int b = 0   # assign a default value for 'b'
"""


More information about the Python-Dev mailing list