We don't use getter methods in Python, instead we use the property decorator to make automatically updating attributes. Properties allow us to customize what happens when you access an attribute.
If you need to make a read-only attribute in Python, you can turn your attribute into a property that delegates to an attribute with almost the same name (but with an underscore prefix).
Want to customize what happens when you assign to a specific attribute on your class instances? You can use a property with a setter.
Have an attribute that takes a while to compute? You could delay the computation until access time with a cached property.
Continue exploring
Learn something new about Python
My name is Trey Hunner. I publish new Python articles and screencasts through Python Morsels. If you want to keep learning new things about Python, join Python Morsels!