ipython/ipython — pull request #6994 by takluyver (2014-11-20 02:07:08+00:00)
Title: Proposal: API to replace current cell

`set_next_input()` makes sense in the terminal, but in the notebook, it's always seemed a bit odd to add a cell in response to things like the %load magic, because re-running the notebook will add the cell again and again.

This adds a `replace=` parameter to `set_next_input()`, defaulting to False. If True, it replaces the current cell contents instead of adding a new cell. In console frontends, the parameter is ignored. I've adapted the `%load` magic to use this, and to add a comment containing the load command at the top of the replacement text, so that it's obvious where it came from:

![screenshot from 2014-11-19 18 06 18](https://cloud.githubusercontent.com/assets/327925/5118411/d9f503f2-7016-11e4-9e28-420c9cb29ad9.png)