Skip to content

Display error messages for invalid kwargs #304

Closed

Description

@fisherds

ev3dev version: 4.4.24-16-ev3dev-ev3
**ev3dev-lang-python version:**0.8.0

As the platform rolls out to more students there are more silly mistakes made. The primary silly mistake I see with my students during their first week is typos with the keyword arguments to the motor functions. Yes, it's a silly goof on their part. I see lots of code like this... (notice the words spedd_sp and postion_sp):

motor_turns_deg = 486
left_motor.run_to_rel_pos(position_sp=motor_turns_deg, spedd_sp=400)
right_motor.run_to_rel_pos(postion_sp=-motor_turns_deg, speed_sp=400)

left_motor.wait_while("running")  # Wait for the turn to finish
right_motor.wait_while("running")  # Wait for the turn to finish

ev3.Sound.beep().wait()

The reason they make this mistake is because PyCharm doesn't know that spedd_sp and postion_sp are an invalid keyword arguments and they are not marked as errors. If they type the function name wrong (run_to_rel_pos) then PyCharm will mark it as an error and students will fix it instantly. However kwargs don't get marked as errors. What happens now is that no error is ever thrown, but the motor doesn't turn since a keyword argument is wrong. That is not terrible, but for new students they don't know what is happening. A descriptive error message would help them a lot. Making their program crash would probably also be good.

So it would be nice for the newbies to either:

  • print a warning of some sort (or throw an exception) when an invalid keyword argument is sent
  • figure out how to make IDE's like PyCharm help check for keyword argument typos.

Just trying to share the mistakes that students are making.

Activity

  1. ddemidov commented on Feb 14, 2017

    @ddemidov
    Member

    This should be covered already by #278, which was recently released as part of 0.8.1. Please update both your kernel and the library.

  2. WasabiFan commented on Feb 14, 2017

    @WasabiFan
    Member

    Please update both your kernel and the library.

    Given that this may not be feasible in a classroom environment, it's worth noting that the only thing that won't work with the new library but an old kernel is the buttons on the EV3. Although, this could be the last release of ev3dev-jessie before we call it "stable" and begin breaking things in ev3dev-stretch, so maybe it's good to get on this release now and then leave it. I can't say for sure what the roadmap looks like though.

    For reference:

  3. fisherds commented on Feb 14, 2017

    @fisherds
    Author

    Awesome! We'll update in the future, so if it's in we're all set. We'll pick it up at some point. Thanks!

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