[Python-Dev] Second post: PEP 557, Data Classes (original) (raw)
Sebastian Rittau srittau at rittau.biz
Mon Nov 27 07:31:26 EST 2017
- Previous message (by thread): [Python-Dev] Second post: PEP 557, Data Classes
- Next message (by thread): [Python-Dev] Second post: PEP 557, Data Classes
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 27.11.2017 13:23, Eric V. Smith wrote:
I had something like your suggestion half coded up, except I inspected the args to postinit() and added them to init, avoiding the API-unfriendly *args and **kwargs. I understand your concerns with *args and **kwargs. I think we need to find a solution for that eventually.
One other thing about InitVar: it lets you control where the init-only parameter goes in the init call. This is especially important with default values:
This is indeed a nice property. I was thinking about that myself and how to best handle it. One use case that could occur in out codebase is passing in a "context" argument. By convention, this is always the first argument to the constructor, so it would be nice if this would also work for dataclasses.
- Sebastian
- Previous message (by thread): [Python-Dev] Second post: PEP 557, Data Classes
- Next message (by thread): [Python-Dev] Second post: PEP 557, Data Classes
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]