3 ms·
The simplest (and still educational) way would be to have the stuff in the different cells as functions, and to collect all the functions that should be re-run
by Tenoke 9y ago
The simplest (and still educational) way would be to have the stuff in the different cells as functions, and to collect all the functions that should be re-run in a single cell.
To do it more properly, however, you can have a post_save_hook for the whole notebook, which runs the code from whichever cells however often you want outside of the notebooks. Of course, this way you wont see the output in the notebook.
- danielvf 9y agoYeah, output right in the notebook is important. I'm wanting them to be able to do something like this in a cell: for ship in myShip.radarScan(): if ship.is_enemy: display([ship.type, ship.range, ship.bearing]) And then have that cells results always showing the current data as they play the game.
- Tenoke 9y agoI haven't used it much, but I believe you can do this by using (or more likely slightly extending) the init_cell nbextension. https://jupyter-contrib-nbextensions.readthedocs.io/en/latest/nbextensions/init_cell/README.html https://jupyter-contrib-nbextensions.readthedocs.io/en/lates...
- danielvf 9y agoOh, that's cool - it's just some javascript that's essentially clicking execute on the selected cells. That makes sense, and hacked up version of this could work fine! Thanks!
- po84 9y ago> And then have that cells results always showing the current data as they play the game. display handles that you can update from elsewhere in the notebook might be of interest. Here's an example: https://github.com/ipython/ipython/blob/master/examples/IPython%20Kernel/Updating%20Displays.ipynb https://github.com/ipython/ipython/blob/master/examples/IPyt...