I posted this last week:
http://m5.posterous.com/slime-like-communication-from-vim-to...
It lets you open a vim session from ipython, and send lines, selections, or the whole file back to the shell. If you'd like to do some hacking, it doesn't seem to be able to send single function definitions yet.