0

hello I have this programm

class zoeken() :
    pass
    def __len__(self):
        return 0 
    def __str__(self):
        return test2
    def find(self, strng="", ch="", start=0, stop=0):
        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 Im getting this error message :

Traceback (most recent call last):
File "C:\Users\wobben\workspace\oefeningen\src\test.py", line 21, in <module>
print test(test2)
AttributeError: zoeken instance has no __call__ method

How to solve this.

Roelof

2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by snippsat
0

Your class look strange,dont see a point with __len__ and __str__ in that class.

test = zoeken()
#calling find method.
print test.find(****) #Takes 4 ****arguments or 0 because of default arguments.
Maybe is better you explain what you want to do?

print test(test2)
You only return test2 in __str__ so how do you think that should work.
Calling method in that class is test.something() not test(something)

Edited by snippsat: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.