Enum possible?
#2404
Replies: 2 comments 1 reply
-
|
You can still write a class that is nearly the same. class MyEnum:
VALUE1 = 1
VALUE2 = 2
...You just won't be able to do If you also need that feature, you could make a class for the values as well. class MyEnumMember:
def __init__(self, name, value):
self.name = name
self.value = value
class MyEnum:
VALUE1 = MyEnumMember("VALUE1", 1)
VALUE2 = MyEnumMember("VALUE2", 2)
... |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
Yeah, that's what I was going to do. I just figured there must be a way to use the standard enum since pybricks was obviously using it with Stop.NONE, Axis.Y, etc. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I tried using the enum class in my code, but it isn't available in pybricks. Apparently it isn't available in micropython. But I wonder then, how is Stop.NONE and Stop.BRAKE available? How can I use enum in my code?
Beta Was this translation helpful? Give feedback.
All reactions