Created
February 1, 2022 20:55
-
-
Save juanarrivillaga/ba995ae238c3192ed0edb5d21bbde064 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BagOfClass(type): | |
class Value: | |
pass | |
def __iter__(klass): | |
for attr_value in vars(klass).values(): | |
if isinstance(attr_value, type) and issubclass( | |
attr_value, BagOfClass.Value | |
): | |
yield attr_value | |
class Tables(metaclass=BagOfClass): | |
class Table1(BagOfClass.Value): | |
"""documentation for first table""" | |
NAME: str = "My First Table" | |
COL11: str = "col11" | |
COL12: str = "col12" | |
COL13: str = "col13" | |
class Table2(BagOfClass.Value): | |
"""documentation for second table""" | |
NAME: str = "My Second table" | |
COL21: str = "col21" | |
COL22: str = "col22" | |
COL23: str = "col23" | |
print(*[table.NAME for table in Tables]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment