I usually get the url like this
response.url
I also get more date from the response.
I wonder if there is a way in which I can pass the things that I want and then use it in the response like this:
x = 'url'
return response.x
I usually get the url like this
response.url
I also get more date from the response.
I wonder if there is a way in which I can pass the things that I want and then use it in the response like this:
x = 'url'
return response.x
 
    
     
    
    You can use getattr:
x = "url"
return getattr(response, x)
From the docs:
getattr(object, name[, default])Return the value of the named attribute of object.
namemust be a string. If the string is the name of one of the object’s attributes, the result is the value of that attribute. For example,getattr(x, 'foobar')is equivalent tox.foobar. If the named attribute does not exist,defaultis returned if provided, otherwiseAttributeErroris raised.
 
    
    