I want to change the way that my function reads in code, so that I can import a class with easier managed variables.
I have all the libraries I want to edit already imported.
class http_request(object):
def __init__(self, website_address, valuedictionary):
self.website_address = website_address
self.valuedictionary = valuedictionary
def get(self):
return requests.get(website_address, params=valuedictionary)
def post(self):
return requests.post(website_address, data=valuedictionary)
def postContext(self):
return requests.post(website_address, data=valuedictionary).context
def getContext(self):
return requests.get(website_address, params=valuedictionary).context
htay = http_request(web_add, payload)
print str(htay.postContext)
I am getting this as my response:
“bound method http_request.get of <main.http_request object at 0x8735cec>>”
Any ideas?
I assume that you wanted to call the method:
Of course, this will probably give you an error about a
global website_address not definedor something of the like because within the method, you need to get the instance attribute viaself:And you’ll need to make the analogous change in your other methods as well.