In ipython >=0.11, the %paste command is required to paste indented commands. However, if I run an ipython shell in a remote terminal, the buffer %paste refers to is on the remote machine rather than the local machine. Is there any way around this?
I think this is exactly what %cpaste
is for (I am always forgetting about all the things IPython does). %cpaste
enters a state allowing you to paste already formatted or indented code, and it will strip leading indentation and prompts, so you can copy/paste indented code from files, or even from an interactive Python session including leading >>>
or In [1]
which will be stripped.
Not a brilliant solution, but I think this will work:
Use %autoindent
to turn off autoindenting, type if True:
and press enter. Then paste your indented code.
I think it should be possible to write an IPython extension to handle this better. I'll try to get round to looking into it. I've made an issue.
If you use IPython a lot, you may want to get the new kernel/client architecture working - it should be possible to tunnel the connections over SSH, so you can use the Qt console on your local machine, talking to a kernel on a server. But that might take a bit of fiddling to get in place.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With