I have problems with the following code, it says "NameError: global name 'Teater' is not defined" I can not solve it by myself...
teaterLista = []
lista = []
class Teater:
def __init__(self, teaterNamn, plats, pensionar,vuxen,barn):
self.teaterNamn = teaterNamn
self.plats = plats
self.pensionar = pensionar
self.vuxen = vuxen
self.barn = barn
def readData():
#x = Teater(x,teaterNamn, plats,pensionar,vuxen,barn)
dataFile = open('c:/Teater.txt','r')
for line in dataFile:
if(line != '\n'):
temp = line.split('=',1)[1]
lista.append(temp.strip()) #strip tar bort radavslut
x = Teater(x,lista[0],lista[1],lista[2],lista[3],lista[4])
#teaterLista[0] = x
#print(teaterLista[0])
readData()
readDataoutside of theTeaterclass work? You might have to do some refactoring to do this -- thereadDatamethod may not belong in that class reading multipleTeaters on an instance of one