Closed carlwgeorge closed 5 years ago
The requests pretty printer is not enabled by default. Run this:
prettyprinter.install_extras(['requests'])
in the shell and then prettyprinter.pprint(r.headers)
and you should have the correct output.
I personally have IPython run a script on startup that sets all the prettyprinter extras and settings I need. If you're using the normal shell, there are some instructions here on how to do that: https://prettyprinter.readthedocs.io/en/latest/usage.html#usage-in-the-default-python-shell
One could make a case for the requests extra to be enabled by default, which would definitely be useful. However, I made the decision to leave all extras opt-in. If the extras get out of date and/or break, or they omit some useful information that the library's own __repr__
method now provides, it's cumbersome to disable pretty printers. And I haven't added any functionality to deregister a pretty printer, which makes it extra cumbersome :)
Ah I didn't realize that. Based on this line in the README I thought that it should work.
requests - automatically pretty prints Requests, Responses, Sessions, and more from the requests library
Are the docs out of date, or do they just need to be elaborated on (some requests types work by default, others need an extra step)?
Also, I'm not seeing a clear explanation in the docs of install_extras
and what it does. Could that be added?
I have clarified in the docs that extras need to be enabled - see https://github.com/tommikaikkonen/prettyprinter/commit/57ef4f25c3ef462ec21338b46c17d4c7c9abe747.
There is an API reference entry for install_extras
but it doesn't communicate much more than the function name. I'll expand on that a bit in the next release.
Awesome, thanks!
Description
requests.structures.CaseInsensitiveDict
does not format correctly with eitherpprint
orcpprint
.What I Did
One can work around it by wrapping the
CaseInsensitiveDict
withdict()
, but it would be nice if this wasn't necessary.