I am working on some Python code, and I would like to call an IPython interpreter from within a script. I have no problem doing this, however, I would then like to dump all of the output from both the script and the interactive session into a new scratch buffer. I know that in general I can use something like
:new | 0read ! <command>
to read the output of a shell command into a new buffer. However, if I try opening up a Python interpreter using that format above what ends up happening is that Vim hangs until I do a bunch of C-c and C-z commands, and finally the output of a Python interpreter with a bunch of C-c and C-z command going into it shows up. Is there any way I could run an interactive program like a Python interpreter, interact with that program as I would normally do, and then have that Python session dumped into a new buffer?