I'm new in python, and I have this code:
class Daemon():
db = Database()
def __init__(self):
final_folder = ''
How I can change the value of the variable final_folder in the same class but in other function?
I try the code like below but isn't work:
class Daemon():
db = Database()
def __init__(self):
final_folder = ''
def get_mail_body(self, msg):
Daemon.final_folder = 'someotherstring'
final_folderis a local variable that ceases to exist once__init__is done executing. You likely want to use an instance variable, in which case, you need to explicitely useself.final_folder = ''then access it withself.final_folderin other methods.