from os import unlink
from tempfile import mkstemp
from subprocess import Popen

def callvim():
    fd, filename = mkstemp()
p = Popen(['/usr/bin/vim', filename])
p.wait()
try:
    return open(filename, 'r').read()
finally:
    unlink(filename)
data = callvim()
print(data)
How can I call Vim from Python?