Replies: 1 comment 3 replies
-
Yeah, Python is dynamic. 😄
Basically, the only difference is that modifying the
I've thought the same before. But never made an official feature request. Feel free to start one.
You could try the dict syntax instead. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Looking through the Color documentation, I see this:
The second way, adding custom colors to the built-in class, feels strange to me. I can't think of another API that I have ever used where the user can modify built in class attributes this way. I mean, it works here, and maybe this is kind of a python thing (I have only been programming python for a couple of years... previously java and c++), but to me it just doesn't seem right from a code organization point of view.
Is there a good reason to use one method over the other that I may not be thinking about?
By the way, two other points:
This was determined by testing, using our competition robot.
And then we have a conversion such that when the sensor sees SENSOR_GREEN, it can then turn the hub button Color.GREEN
I don't know what pybricks could or should do differently since theoretically each sensor is probably a bit different, especially when considering the different ways it may be installed.
Anyway, I point this out to start the conversation. Maybe there is something pybricks could do to make it easier for detecting colors.
The code still runs, but it looks like there are errors when there aren't. Turning mypy off "fixes" this, but something tells me it can be improved. I'd consider this very low priority, but perhaps something to start thinking about.
Beta Was this translation helpful? Give feedback.
All reactions