J
Johan
I don't get it:
I'm trying to write a "readfile" function which would replace some code from
a __init__ function:
1 import string
2 class landdict:
3 def __init__(self, file):
4 # Laadt de dictionnary van landen.
5 # Kijk in de actiefspel-file voor de file van waaruit je
moet laden.
6 self.ld = {}
7 f = open(file, "r")
8 line = f.readline()
9 if line[0] == "#":
10 line = f.readline()
11 while line != "":
12 key = line[0:3]
13 self.ld[key] = string.split(line[4:], ':')
14 line = f.readline()
15 print self.ld
So I would like to replace the code from line 7 to line 14 with
readfile(filename)
while
def readfile(filename) is another function in the class
but I can't define this function.... when I call the function the
interpreter throws an exception of unknown function
what am I doing wrong?
--
____________________________________________________
Johan Potums
Vaartstraat 67
3000 Leuven
(e-mail address removed)
I'm trying to write a "readfile" function which would replace some code from
a __init__ function:
1 import string
2 class landdict:
3 def __init__(self, file):
4 # Laadt de dictionnary van landen.
5 # Kijk in de actiefspel-file voor de file van waaruit je
moet laden.
6 self.ld = {}
7 f = open(file, "r")
8 line = f.readline()
9 if line[0] == "#":
10 line = f.readline()
11 while line != "":
12 key = line[0:3]
13 self.ld[key] = string.split(line[4:], ':')
14 line = f.readline()
15 print self.ld
So I would like to replace the code from line 7 to line 14 with
readfile(filename)
while
def readfile(filename) is another function in the class
but I can't define this function.... when I call the function the
interpreter throws an exception of unknown function
what am I doing wrong?
--
____________________________________________________
Johan Potums
Vaartstraat 67
3000 Leuven
(e-mail address removed)