forked from samgiles/slumber
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added requests arguments to session samgiles#105
Added the ability to pass session wide parameters to the requests.Session object.
- Loading branch information
1 parent
4c4b7bc
commit 3a54d56
Showing
1 changed file
with
12 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3a54d56
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What value does this actually provide? You can do this easily in your own code and then pass in the prepped session object. IMHO this is better solved by documentation, showing how to do it for typical use cases (e.g. the U-A header).
The above solution will always be restricted to what you provided as "magic" names there, and won't evolve with newer requests versions. Outside initialization has no such restrictions.
3a54d56
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You make an interesting point. This is just a quick fix for the "lazy" ones. As you can see, my code doesn't break anything as session_params is an optional parameter that can be passed.Would you think it would be better to add this to the documentation on slumber and still leave this code on?
3a54d56
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code is a liability – it has to pay for its existence/maintenance in function or convenience. The above code falls into the 2nd category, and IMHO falls short, because the code the caller has to write to prepare that dict parameter is about the same as to prepare the session object (once you know via docs that this is the way). Also quoting The Zen:
There should be one-- and preferably only one --obvious way to do it.
So if you ask me docs only is the way to go here, via concrete examples from real use-cases.