First, quick introduction. I’m a not-so-young physicist who programs a good bit, mostly C++. I only just looked at Python a few weeks ago. Decorators are very neat. __setattr__ and/or properties are just super to allow one to just get on with the coding.
But I like clear interfaces, declared/self-documented up top, and not having assignment to typos go silently unnoticed. I noticed dataclasses, which provide a great format for something like that, and even saw discussions on abusing slotted dataclasses for some amount of declaration enforcement, with some inheritance limitations I believe.
Anyway, to the point:
The readme gives the short version. A test script is included. The wiki gives some related thoughts on encapsulation, along with an included demo script for that as well.
This repo represents half of my total python portfolio, so I expect that shows. I know of a couple of issues, mentioned in the readme or issues. But, it does work (and already caught a couple of my typos in “production” code!), so I thought I’d share. Is the concept useful for python core? I don’t know. I think a more comprehensive version could deal with some of the encapsulation things in a more clean pythonic way, but I doubt I’ll be adding that personally. I think there have been some discussions and developments on that aspect already.