For example, I need for class calling returns string.
class Foo(object):
def __init__(self):
self.bar = 'bar'
def __call__(self):
return self.bar
Foo calling returns Foo object.
Foo()
<__main__.Foo object at 0x8ff6a8c>
What should I do to class returns string or other? How to use __call__?
With your example (of limited usefulness), you have a class of callable objects.
You can do now, as you have done,
I. e.,
__call__()does not make your class callable (as it is already), but it gives you a callable object.