I have a question about classes in Python. I have create a class that looks something like this:
class Model(Object):
__table__ = 'table_name'
def func():
def func2():
The table name is a global variable that the functions feed off of. I am trying to add old data so I would like to change the table name depending on if I am filling in from old information, so this is what I tried.
class Model(Object):
def __init__(self, backfill = False):
self.backfill = backfill
if self.backfill:
__table__ = 'table_name'
else:
__table__ = 'table_name2'
def func():
def func2():
The final call would be something like this:
if backfill:
model = Model(True).func()
else:
model = Model.func()
Then I realized this wouldn't work because I cannot call self.backfill from outside the class definitions. I even tried creating a definition and calling that inside the class but that did not work either.
My question is:
- Is there a way to initialize the global variable inside the class from the class variables? Or is there a better way to do this in general?