I defined an enum class and would like to be able to use its attributes without need to access it through class name. I mean:
class MyEnum:
ONE = 1
TWO = 2
...
if MyEnum.ONE == 1:
"Typic use"
if TWO == 2:
"My desire"
Is there a way to do this?
In my specific context, I'm calculating points externality of a window through Cohen–Sutherland algorithm, so I have the following code:
class Externality:
INSIDE = 0
LEFT = 1
RIGTH = 2
BELLOW = 4
ABOVE = 8
# And at some point:
((x, y), externality) = actual
if not Externality.INSIDE in externality:
del cohen_sutherland_list[0]
So, the needed of express Enum's name to access its items make the if
statement (and the whole code) a little more verbose and redundant.