Guideline for attributes #52
|
When going through the code I found different ways of how attributes are implemented and I also wasn't entirely sure what to go for myself when doing changes. So I thought deciding on a guideline would be good. This is my suggestion:
|
Replies: 3 comments 3 replies
|
I think your suggestion is alright. I only slightly disagree on get and set. I don't mind so much having get/set functions instead of properties, even if it is not so Pythonic. Maybe the guidelines should be added to CONTRIBUTING.md or to some other visible place. |
|
I'm not sure to fully understand, do you want to add some # Set up the chromaticy monitor (override config settings)
CM = SR.get_chromaticity_monitor("CHROMATICITY_MONITOR")
CM.n_step =3 # 3 point for chroma fit
CM.n_avg_meas = 1 # No averaging`And in the model you |
The suggestion is just to follow the Python standard that private attributes that are not meant to be part of the public interface of a class should use a
_. This is to indicate to the developers that they should not be called by users or other classes, but only internally in the same class.The attributes that are part of the public interface should have no underscore. For cases where the attribute should be read only or you need some logic in the setter (for example to validate the data before changing it) you would make a private attribute and combine it with a property for implementing the getter/setter functionality.
For your example I imagine that
n_stepandn_avg_measprobably can …