title: Execute a block of python code with exec, capturing all its output?
body: <p>What's a good way to exec a bunch of python code, like <code>exec mycode</code>, and capture everything it prints to stdout into a string?</p>