Contribute Media
A thank you to everyone who makes this possible: Read More

Encapsulation with descriptors

Summary

Python has no private fields, but the property decorator lets you replace public attributes with getters and setters without breaking client code. And the descriptor mechanism, used in Django for model field declarations, enables wide reuse of getter/setter logic via composition instead of inheritance. This talk explains how properties and descriptors work by refactoring a practical example.

Details

Improve this page