3 ms·
PrePostInitMeta is just adding what's already in the stdlib dataclasses, but making it available to other classes too.
by jph00 6y ago
PrePostInitMeta is just adding what's already in the stdlib dataclasses, but making it available to other classes too.
- nemetroid 6y agoDataclasses have __post_init__, but they don't have a __pre_init__, do they? From what I can tell, PrePostInitMeta adds a completely new __dunder__ method with pre_init.
- hansvm 6y agoAgreed (mostly...it looks more powerful than dataclasses afaict). It looks like it could have a ton of use cases. My concern is that it seems easy to get started, but metaclass hackery is hard to get right if you do much of it. Maybe that fear is unfounded; have you found that people tend to use it responsibly? As a small side-note, on the surface I'm not seeing any reason it couldn't be implemented with something more composable like __init_subclass__, and that might be a nice touch.