The web is full with python code examples that are either taken from vanila Python shell
>>> for i in range(10):
... print(i)
...
.... or from IPython shell:
In [1]: for i in range(10):
...: print(i)
...: print(i + 1)
...:
When I want to paste such snippets into IPython, I need to paste them into a text editor, do some find-and-replace and then paste it into IPython. I'm sure there is a better way, but can't find it.
The
%paste
command works, but what I was actually looking for was%doctest_mode
. More cool hacks can be found hereIn IPython you can call
%paste
it will paste your clipboard in terminal.Note: As far as I know you should install
tkinter
for using%paste
.