О©╫О©╫О©╫О©╫О©╫О©╫О©╫, 18 О©╫О©╫О©╫О©╫О©╫О©╫О©╫ 2012О©╫О©╫., 0:51:46 UTC+4 О©╫О©╫О©╫О©╫О©╫О©╫О©╫О©╫О©╫О©╫О©╫О©╫ Vlad Irnov О©╫О©╫О©╫О©╫О©╫О©╫О©╫:
py3<<EOLin $MYVIMRC
def python_with_print(*args):
О©╫ global py_res
О©╫ py_res=None
О©╫ try:
О©╫О©╫О©╫О©╫О©╫ eval(compile('py_res='+' '.join(args),'<string>','exec'),globals())
О©╫ except:
О©╫О©╫О©╫О©╫О©╫ eval(compile(' '.join(args),'<string>','exec'),globals())
О©╫ print(py_res)
EOL
command! -narg=* Py py3 python_with_print(<f-args>)
:Py from math import *an you would get results or None on the command line.
:Py sin(30*pi/180)
But why not be a bit more verbose out of the box? I mean I could have just used one of the plugins listed by Vlad or script written by Roland, I admit these are good solutions, but I think default implementation is too much quiet.
Now You may run ":py f = open("/some/file/doesn/t/exist")" and see no error at all, or ":py vim.current.line" without expected output.
Among other things I like vim because of its succinctness, so I can type less and get more, that's why I think this patch would fit perfectly well without option disabled by default.