On 16/09/12 18:32, Simon W. Jones wrote:
Hello,
I am trying to capture the stdout (a simple digit) from a python script that I
am calling from vim and assign it to a variable. I have been trying redir but
can't seem to get it to work.
Any help would be appreciated!
Thanks.
Simon.
Unless your Python script is using the Vim-Python interface (using
"import vim" etc.) you might run it independently:
:let py_retval = system('python mynicescript.py')
see :help system()
Or you might try to capture the stdout by means of the :redir statement
(see ":help :redir") but I don't know if it works:
(untested)
:redir => py_retval
:pyfile mynicescript.py
:redir END
:echo 'Result = «' . py_retval . '»'
Also, this might add ends-of-lines before and/or after your "single
digit" answer.
Best regards,
Tony.
--
We are all in the gutter, but some of us are looking at the stars.
-- Oscar Wilde
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php