Answer the question
In order to leave comments, you need to log in
How not to repeat a certain method every time a method is called?
Perhaps my wording is too abstract.
But here's the problem:
There is a class that represents the model (eg City, Street, House). It has methods that represent (that's right :)) methods of some API, for example:
class House(Api):
def get_house_address(self):
self.method('getAddress')
return self.process(self.data) #parent method
def get_neighbourhoods(self):
self.method('getClosestHouse')
return self.process(self.data)
Answer the question
In order to leave comments, you need to log in
I will answer a little differently.
You most likely don't need to do this.
You don't have to do this because your code is clean, readable, and easy to maintain.
And before you do anything, you should answer the question why you are not satisfied with the current code.
What characteristics of the code do not suit you, that you want to change them?
If you are still able to answer this question, then maybe you should dig in this direction:
stackoverflow.com/questions/6307761/how-can-i-deco...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question