Imagine A Color API
class Color(object):
def __init__(self, hex):
self.hex = hex
def _request_colour_name(self, hex):
print "Requesting #{}".format(hex)
rsp = requests.get(API_ENDPOINT.format(hex))
return rsp.json()[0].get("title")
@property
def name(self):
return self._request_colour_name(self.hex)