Is there a Python equivalent / pseudo-equivalent to java's OutputStream or PrintWriter?
I want to be able to have a handle that represents either a stream like stdout/sterr, or a file, or something else (a pipe or a socket or a dummy sink) and abstract away what kind of thing it is, so I can just send output to it.
How can I do this?