1

Say I have several get/post requests to several pages of the same website, and I will want to pass in the updated cookies all the time to the next session get/post. Do i need to keep typing

session.get('http://google.com',cookies=jar) 

all the time? (Assuming jar is an already initialized cookiejar. I know the JavaScript (node) version has a method called

requests.defaults() 

what about python?

Thanks

2
  • Which module are you using? urllib, requests? Commented Jun 14, 2017 at 6:28
  • I've looked at the requests code, and there is no method likerequests.defaults() in Node.js. In my case, I'm writing an SDK, and I wanted to have a way to set default headers during testing without having to change the core objects. Commented Oct 17, 2017 at 13:32

1 Answer 1

1

To add default arguments, you can utilize python's dict and keyword argument functionality:

std_args = {"cookies": jar, "timeout": 5} session.get('http://google.com', **std_args) session.post(url, json=myjson, **std_args) 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.