8. Enums¶
Printed pconfigs are interpretable python code, provided that the printed representation of all parameter values can be interpreted as python code. Python Enums are one case for which the default python representation (repr) cannot be interpreted as python code.
8.1. Use @penum to print interpretable Enum values.¶
from pconfigs.pinnable import penum
@penum
class Color:
red = "red"
blue = "blue"
The printed enum representation can be interpreted:
>>> print(repr(Color.red))
Color.red
whereas a typical python Enum would print <Color.red: 'red'>, which cannot be interpreted as python code.