Skip to content

Instantly share code, notes, and snippets.

@juanarrivillaga
Created February 1, 2022 20:55
Show Gist options
  • Save juanarrivillaga/ba995ae238c3192ed0edb5d21bbde064 to your computer and use it in GitHub Desktop.
Save juanarrivillaga/ba995ae238c3192ed0edb5d21bbde064 to your computer and use it in GitHub Desktop.
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