[Tutor] class method problem
Roelof Wobben
rwobben at hotmail.com
Sat Sep 25 20:15:03 CEST 2010
Hello,
I have this code:
class zoeken() :
pass
def __len__(self):
return 0
def __str__(self):
return test2
def find(self, strng, ch, start, stop):
index = start
while index < len(strng) and index < stop:
if strng[index] == ch:
return index
index += 1
return -1
test = zoeken()
test.woord = "tamara"
test2 = zoeken.find(test, "a", 1,5)
print test(test2)
But now I get this message :
Traceback (most recent call last):
File "C:\Users\wobben\workspace\oefeningen\src\test.py", line 20, in <module>
test2 = zoeken.find(test, "a", 1,5)
TypeError: find() takes exactly 5 arguments (4 given)
I can do zoeken.find (test2,test, "a", 1,5) but then I get this message:
Traceback (most recent call last):
File "C:\Users\wobben\workspace\oefeningen\src\test.py", line 20, in <module>
zoeken.find( test2, test, "a", 1,5)
NameError: name 'test2' is not defined
Roelof
More information about the Tutor
mailing list