That is the most universal way to "print" an object, it's just that not every object will have a very useful printout; most probably don't, in fact.
If you're working with an object someone else created, you'll often want to look at the documentation to find out how to look at its variables and whatnot. That will often give you the prettiest output. Other answers to this question offer a more general way of inspecting an object, which can be a lot faster and easier than looking up documentation; they do a more shallow inspection, as far as I can tell, but they're a good starting point.
If you're making your own object, you'll want to define a method called __str__()
that returns a string. Then, whenever you say print obj
, that object's __str__()
function will be called, and that string will be returned.
In your case, if you have a request.Session()
object named my_obj
, you can apparently print it with print(my_obj.text)
, according to the documentation.
http://docs.python-requests.org/en/latest/user/advanced/