2

I am using gvim in interaction with IPython 0.12 on a linux box.

I would like to see the output of my *.py script displayed in the Ipython console, but I haven't managed to tweak the parameters accordingly.

Typically if I write something like

print sum([1,2 3]) 

I would expect the result to display in the console. Actually I only get a message displayed in the lower vim area giving an input number for the execution (In[2] say). But the display In[1] wouldn't change in the Ipython konsole.

Thanks for insight.

2 Answers 2

2

What you said sounds like the expected result, but I think I know what you are going for.

You could use something like tmux to send a command to a terminal session (using send-keys). So you would have one terminal that shows the output of your program, and another with vim. Vim would send a command (something along the lines of tmux send-keys "python your.program^M") to the other terminal to run your script.

Another option you have is to have vim execute your script, but redirect the output to a file. Vim would execute something like python yourscript.py > /tmp/out & and your other terminal would be running tail -F /tmp/out so it will continuously update.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for suggestions, actually I find out that %run file.py executed in the ipython shell will produce the expected output.
...wasn't able to edit my previous comment. Thanks for suggestions, actually I find out that %run file.py executed in the ipython shell will produce the expected output. Now I check the ipy.vim plugin to discover that <F5> actually runs def run_this_file(): msg_id = send('run %s %s' % (run_flags, repr(vim.current.buffer.name),)) print_prompt("In[]: run %s %s" % (run_flags, repr(vim.current.buffer.name)),msg_id) Do you see an easy tweak in this function? Thanks
1

I'm one of the IPython developers, and wrote vim-ipython (from which you're using ipy.vim).

The behavior you are seeing is simply a wanted feature that has not been implemented in IPython yet: ipython console, ipython qtconsole, and the web notebook do not currently print activity that they did not initiate. See the discussion on issue #1873 for this planned feature enhancement.

The In[] prompt will get update once you actually try to send a new command in ipython's qtconsole.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.