Copy code from IPython without leading triple dots Copy code from IPython without leading triple dots python python

Copy code from IPython without leading triple dots


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 1def foo():    return 1+2


One of the cool features of ipython is session logging. If you enable it, the code you input in your session is logged to a file. It's very useful, I use it all the time.

To make things even niftier for me, I have a shell alias ipy_log_cat, which prints the entire file. You can do something like: ipy_log_cat | tail to get the most recent input lines. (this is also useful for greping session history, etc.). You can also save a few keyboard/mouse strokes by piping it into xclip!


This QTconsole copy regression has been fixed, see https://github.com/ipython/ipython/issues/3206 - I can confirm that the desired behavior is again present in the QtConsole in the Canopy 1.2 GUI and, I suspect, in the ipython egg installable by free users from the Enthought egg repo.