Answer the question
In order to leave comments, you need to log in
How to extend someone else's python library?
Noob and confusing question.
I have a library that makes a request to the API, it is used like this:
LOGIN = "user"
PASSWORD = "pass"
API_URL = "http://..."
api = library.Api(API_URL, LOGIN, PASSWORD)
#api.get(something)
#...
api = library.Api(API_URL, LOGIN, PASSWORD)
api.get_something_specific()
Answer the question
In order to leave comments, you need to log in
Create a class that inherits from library.Api
. Or implement the desired logic as a separate function, not a method:
#...
api = library.Api(API_URL, LOGIN, PASSWORD)
get_something_specific(api)
You can use a decoy patch.
Rough example:
def get_something_specific(self, *args):
pass
api.get_something_specific = get_something_specific
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question