I'm writing a class to get data from an API. I have functions that I want to perform on the class e.g.
self.do_this()
I also have functions that are supposed to do things within that function, e.g.
def do_this_part(response):
Dict = {}
for key, value in response.items():
Dict[key] = value
return Dict
I want to have a smaller function inside the class so that it always comes within the class. It will never be performed on the class but will be performed within multiple functions that will be performed in the class.
I am getting the following error:
NameError: name 'do_this_part' is not defined
So clearly I'm not defining the function in the right place. My apologies if this is a fairly basic question that has been answered before, I searched and couldn't find the answer.
do_this_partis inside the class, you need to call it asself.do_this_part(response). Also you need to change its signature so that it takesselfas the first argument, andresponseas the second.