hello I have this programm

class zoeken() :
    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.


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)