Imagine a class that works like a container of database table information (table names and columns).
This is an implementation.
class TABLES(Enum):
class TABLE1:
""" documentation for first table """
NAME = "My First Table"
COL11 = "col11"
COL12 = "col12"
COL13 = "col13"
class TABLE2:
""" documentation for second table """
NAME = "My Second table"
COL21 = "col21"
COL22 = "col22"
COL23 = "col23"
My goal would be to access the value of the enum (which are the classes TABLE1
or TABLE2
) without explicitly calling the value
attributes.
So if for example I want to concatenate the first two columns of the first table I want to write
TABLES.TABLE1.COL1 + TABLES.TABLE1.COL2
instead of
TABLES.TABLE1.value.COL1 + TABLES.TABLE1.value.COL2
I don't need the class TABLES
to be an enum, but I have two requirements:
TABLES
needs to be iterable- I'd like to see the whole choice of tables once I write
TABLES.
Moreover, I need single tables to be classes because I want to add a small documentation on each of them.