I have an example IntEnum class:
class ShapeMethod(IntEnum):
NONE = 0
circle = 1
square = 2
That needs to be called by the __init__ function of another class:
class ExampleClass():
def __init__(look_at_shapes=None):
"""
Args:
look_at_shapes (dict): A dictionary of shape inputs.
"""
if look_at_shapes:
self.shape = ShapeMethod.NONE
if look_at_shapes["colour"]:
self.colour = look_at_shapes["colour"]
def do_something_with_shape:
if self.shape == ShapeMethod.circle:
print('awesome you got a circle'.)
elif self.shape == ShapeMethod.square:
print('squares have 4 sides.')
else:
print('nothing to see here.')
where, the self.shape attribute needs to be circle, square or NONE.
The do_something_with_shape function would then be called by:
input = {"colour" = blue}
my_object = ExampleClass(look_at_shape=input)
my_object.do_something_with_shape
The structure of input needs to be a dictionary, and it is reasonably simple to set the colour. However, I do not know how to properly use the IntEnum class from inside a dictionary. For example, if I want to print squares have 4 sides.
Note: Do all options in ShapeMethod(IntEnum) need to be capitalized?
What I have looked at so far:
The documentation for Python gives a number of examples; however, none fit my exact case.