In the Python interactive interpreter:
I am importing a module that contains a class. These are the methods of that class (some of them):
def do_api_call(self, params):
return self.__apicall(params)
def __apicall(self, params):
return urllib2.urlopen(self.endpoint, params).read()
When I import the class and use the method do_api_call(), it doesn't output anything when it finishes running.
def do_api_call(self, params):
print(self.__apicall(params))
def __apicall(self, params):
return urllib2.urlopen(self.endpoint, params).read()
I create an instance of the class and run the method:
myapi = MyAPIClass()
myapi.do_api_call(params={'param': 'value'})
When I do the second version (note the print function) however, it outputs the HTML of the page that is being called.
Why doesn't the first version output anything? It's working (ie, it's getting the page and not raising any errors).