Property usage
wsdewitt opened this issue · 3 comments
wsdewitt commented
In multidms.Data
there are numerous @property
definitions based on attributes with the following form, where the property with a name like attr()
seems to only function as a way to publically expose a private attribute with a name like self._attr
:
@property
def attr(self):
"""Docstring."""
return self._attr
Maybe there's something I'm missing, but it seems like this could all be simplified by:
- change the attribute names to public (removing the underscore)
- remove the property wrappers
- document the newly-public attributes in the class docstring
jgallowa07 commented
@wsdewitt Properties by default are essentially getters for private attributes so they remain static/immutable. This provides exactly the behavior I want unless I'm missing something.
jgallowa07 commented
e.g. I want al those attributes exposed (without a function call), but the property makes it impossible to
data.attr = "I like hairy caterpillars"
wsdewitt commented
Ah, ok. I agree this is the way to stop users from assigning to these attributes.