Running Code Snippets in Vim Buffers
I discovered this trick while trying to do some quick investigation in Vim, and not wanting to have to leave the editor, found a way to quickly replace Python code with its output.
What you do is, write the code inside a buffer, then select it in visual mode. Once it's selected, press : and you will get Vim's :'<,'> range. Then you can pipe it:
:'<,'>!python
This replaces the selected text with the output of the Python interpreter.