[Python-Dev] Second post: PEP 557, Data Classes (original) (raw)
Sebastian Rittau srittau at rittau.biz
Mon Nov 27 06:01:52 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 25.11.2017 22:06, Eric V. Smith wrote:
The updated version should show up at https://www.python.org/dev/peps/pep-0557/ shortly.
This PEP looks very promising and will make my life quite a bit easier, since we are using a pattern involving data classes. Currently, we write the constructor by hand.
The major changes from the previous version are:
- Add InitVar to specify initialize-only fields.
This is the only feature that does not sit right with me. It looks very obscure and "hacky". From what I understand, we are supposed to use the field syntax to define constructor arguments. I'd argue that the name "initialize-only fields" is a misnomer, which only hides the fact that this has nothing to do with fields at all. Couldn't dataclassses just pass *args and **kwargs to post_init()? Type checkers need to be special-cases for InitVar anyway, couldn't they instead be special cased to look at post_init argument types?
- 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 ]