Inserting a new cell from python ?

31 views
Skip to first unread message

nicolas....@synchrotron-soleil.fr

unread,
Jan 18, 2017, 7:36:13 AM1/18/17
to Project Jupyter
Hi all,
Is there a way to insert a new cell below the current cell from python?
The idea would be to mimic what the '+' button (or Esc-B sequence) does from the notebook page.
Thanks.
N.

Fernando Perez

unread,
Jan 18, 2017, 3:05:26 PM1/18/17
to Project Jupyter
This should do the trick for you:

contents = "hello"

shell = get_ipython()
shell.set_next_input(contents, replace=False) 

###

Cheers,

f

nicolas.fr

unread,
Jan 18, 2017, 6:24:37 PM1/18/17
to Project Jupyter
That works. Thanks Fernando.
Reply all
Reply to author
Forward
0 new messages