Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Copy code from IPython without leading triple dots

Tags:

I'm using IPython Qt Console and when I copy code FROM Ipython it comes out like that:

    class notathing(object):         ...:         ...:     def __init__(self):         ...:         pass         ...: 

Is there any way to copy them without those leading triple dots and doublecolon?

P.S. I tried both Copy and Copy Raw Text in context menu and it's still the same. OS: Debian Linux 7.2 (KDE).

like image 592
LetMeSOThat4U Avatar asked Dec 31 '13 13:12

LetMeSOThat4U


People also ask

How do you view full length output in Jupyter notebook?

To show the full data without any hiding, you can use pd. set_option('display. max_rows', 500) and pd.

How do you escape IPython?

Entering (and exiting) ipython You can also hit Ctrl-D to exit out of ipython. In fact, using your keyboard is the most highly recommended way.

Is IPython an interpreter?

IPython is a powerful interactive Python interpreter that is more interactive comparing to the standard interpreter. To get the standard Python interpreter you type python and you will get the >>> prompt from where you can work. To get IPython interpreter, you need to install it first.


1 Answers

How about using %hist n to print line n (or a range of lines) without prompts (including line continuations), and doing your copy from that? (Simply scrolling back to that line is nearly as good).

In [1]: def foo():    ...:     return 1+2    ...:   In [6]: %history 1 def foo():     return 1+2 
like image 187
hpaulj Avatar answered Oct 11 '22 12:10

hpaulj