C
c james
Given a condition at the time a class is instantiated, I want to change
how __call__ is used. From the example below, self.no is using self.yes
but self.__call__ is not. Can someone please explain why?
EXAMPLE:
class YesNo(object):
def __init__(self, which):
self.no = self.yes
self.__call__ = self.yes
def yes(self, val):
print 'Yes', val
def no(self, val):
print 'No', val
def __call__(self, val):
raise NotImplementedError()
Traceback ....
Not ImplementedError
how __call__ is used. From the example below, self.no is using self.yes
but self.__call__ is not. Can someone please explain why?
EXAMPLE:
class YesNo(object):
def __init__(self, which):
self.no = self.yes
self.__call__ = self.yes
def yes(self, val):
print 'Yes', val
def no(self, val):
print 'No', val
def __call__(self, val):
raise NotImplementedError()
Traceback ....
Not ImplementedError