Working with classes in one of my projects for the first time, I seem to be making a mistake somewhere that I can’t pick.
class aiRespond:
def generateResponse( self, external_input ):
return external_input
def giveResponse( self, external_input ):
self.generateResponse(self, external_input)
aiResponder = aiRespond()
retrieve_ai_response = aiResponder.giveResponse()
while 1:
external_input = raw_input("> ")
print retrieve_ai_response(external_input)
Error:
TypeError: unbound method giveResponse() must be called with aiRespond instance as first argument (got str instance instead)
I have tried many different ways of structuring this. I would prefer retrieve_ai_response = aiRespond.giveResponse to be in one line as I am going to have a lot of things similar to this.
Would someone mind pointing out where I’m going on and why?
I have modified you code,Hope it works!