You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
"Special" sensors use methods instead of properties #228
After some conversation with @ndward about errors he was seeing, I have realized that the "special" sensors are implemented with normal methods for each property instead of "real" Python properties. Why is this? If it's possible, I think it would probably be best to use the standard templates for the special sensors as well so any changes we make to the other classes also affect these ones.
I expect that the main reason for this is that the special sensors take a parameter to determine if they set the mode. I think it would be better to create some separate way of doing that so that we don't sacrifice the property-style access of these values.
One reason I can give, is that special methods now take optional parameter (do_set_mode=True, result of discussion in ddemidov/ev3dev-lang-cpp#10). It would be impossible to reimplement this with a property.
Oops, did not see your edit. Well, we could create a set of two properties for each method, or maybe create a class-wide flag (s.set_mode_on_each_access=False; print(s.is_pressed))
we could create a set of two properties for each method
I could get on board with that. We'd need to make sure that it doesn't get confusing when looking at the docs though.
or maybe create a class-wide flag (s.set_mode_on_each_access=False; print(s.is_pressed))
This requires some more thought on our part about the use cases here, but I think this option would be preferable over the first.
Overall, do you think that this change would be worth the benefit of using properties? I think it's moderately more intuitive, but at the same time these are all get-only, so presumably the idea of a method that returns a property value wouldn't be foreign to users anyway.
Activity
ddemidov commentedon Oct 14, 2016
One reason I can give, is that special methods now take optional parameter (
do_set_mode=True, result of discussion in ddemidov/ev3dev-lang-cpp#10). It would be impossible to reimplement this with a property.ddemidov commentedon Oct 14, 2016
Oops, did not see your edit. Well, we could create a set of two properties for each method, or maybe create a class-wide flag (
s.set_mode_on_each_access=False; print(s.is_pressed))WasabiFan commentedon Oct 14, 2016
I could get on board with that. We'd need to make sure that it doesn't get confusing when looking at the docs though.
This requires some more thought on our part about the use cases here, but I think this option would be preferable over the first.
Overall, do you think that this change would be worth the benefit of using properties? I think it's moderately more intuitive, but at the same time these are all get-only, so presumably the idea of a method that returns a property value wouldn't be foreign to users anyway.
Special sensor properties are really properties now
[breaking] Special properties (#229)
ddemidov commentedon Oct 28, 2016
Resolved by #229