I've started to build my class in this fashion (more like a regular function):
ex 1
class Child(Parent):
def __init__(self,user):
Parent.__init__(self, user)
search = api.search()
filter = api.filter(search)
output = api.output(filter)
return output
this way I could run:
movies = Child('John')
and get my final output.
Then, I broke my global api methods into instance methods in order to have more control of data:
ex 2
class Child(Parent):
def __init__(self,user):
Parent.__init__(self, user)
def search_api(self):
search = api.search()
return search
def filter_api(self, search):
filter = api.filter(search)
return filter
def output(self, filter):
output = api.output(filter)
return output
and now I have to break it in different instances, to get the final output:
test = Child('John')
search = test.search_api()
filter = test.filter_api(search)
out = test.output(filter)
print (out)
Is there a decorator or built-in method that allows me to chain all instance methods so that ex2 can be run in one shot (instantiation)?
test.output(test.filter_api(test.search_api()))?ex2you aren't using the arguments in your methods? I can't imagine it would do what you wanted in that case.__init__is superfluous because it does nothing more than the superclass' does, and none of the methods ever useself, so they could just as well be perfectly normal functions.__init__- that doesn't work either.