I am new to python and am struggling with classes. Here is my code.
class sgrid(filename):
def __init__(filename):
filename = self.filename # do I need these?
print_to_app2 = self.print_to_app2 # do I need these?
def print_to_app2(text):
print(text)
def iterate(filename):
self.print_to_app2(filename)
self.print_to_app2('Application is initializing')
if __name__ == '__main__':
sgrid=sgrid()
filename = "a_file_name"
sgrid.iterate(filename)
I get this error: NameError: NameError: name 'filename' is not defined
What am I doing wrong? I want to be able to call functions within this class and outside it.