I was looking for a way to add some sort of decorator that applies to all instances of requests.get being used in any function.
For example,
@my_custom_decorator
def hello():
...
r = requests.get('https://my-api-url')
...
The my_custom_decorator could then add a common param (or anything else) for all instances of requests.get. One will only need to add the decorator whereever requests.get is being used.
For now, I'm thinking of somehow checking if the original function contains presence of requests.get, but that seems not to be ideal.
Note: Also, I'm looking not to change any existing instances of requests.get..hence looking for a better way to achieve this.
from Add decorator for python requests get function
No comments:
Post a Comment