Skip to content

"Special" sensors use methods instead of properties #228

Closed

Description

@WasabiFan

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.

Activity

  1. ddemidov commented on Oct 14, 2016

    @ddemidov
    Member

    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.

  2. ddemidov commented on Oct 14, 2016

    @ddemidov
    Member

    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))

  3. WasabiFan commented on Oct 14, 2016

    @WasabiFan
    MemberAuthor

    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.

  4. added a commit that references this issue on Oct 28, 2016
  5. ddemidov commented on Oct 28, 2016

    @ddemidov
    Member

    Resolved by #229

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions