4 ms·
Awesome. I've always been curious over examples of clean architecture in Python. I had a cursory glance. As a suggestion, I think the `Room` domain model could
by MrSaints 8y ago
Awesome. I've always been curious over examples of clean architecture in Python. I had a cursory glance. As a suggestion, I think the `Room` domain model could be improved with dataclasses (https://docs.python.org/3/library/dataclasses.html https://docs.python.org/3/library/dataclasses.html).
- thedigicat 8y agoAh, you already know what you will find in the next releases of the book =) Thank for the suggestion, actually I was struck by dataclasses as they are exactly what I needed for a project I have, a sort of library for clean architectures. We'll see. Thanks!
- BerislavLopac 8y agoOr even more by attrs: https://www.attrs.org/en/stable/ https://www.attrs.org/en/stable/
- jimbo1qaz 8y agoTry @attr.dataclass. It uses the cleaner 3.6+ dataclass syntax, but is more flexible (supports kw-only classes).
- thedigicat 8y agoThank you both for your suggestions, I will consider using one of these in the next versions of the book. Python is a moving target, so I will have to update the examples.
- MrSaints 8y agoI've recently also come across https://pydantic-docs.helpmanual.io/ https://pydantic-docs.helpmanual.io/ which appears to be useful for enforcing simple constraints on domain entities.