Whats the recognised way of doing enumerations in python?
For example, at the moment I’m writing a game and want to be able to move “up”, “down”, “left” and “right”. I’m using strings because I haven’t yet figured out how enumerations work in python, and so my logic is littered with things like this:
def move(self, direction): if direction == "up": # Do something
I want to replace
"up" with something like
class Directions: up = 0 down = 1 left = 2 right =3
Answered By – Kugel