Proxying Python file-like objects for fun and profit

As part of a project I’m working on, I wanted to be able to do some “side processing” while writing to a file-like object. The processing is basically checksumming on-the-fly. I’m essentially doing something like: source = get_a_readable_file_like_object() destination = get_a_writable_file_like_object() destination.write(source.read()) what I’d like is to be able to also get the data read […]