[IPython-dev] Loop over a set of notebook cells?
clyde.fare at gmail.com
Mon Mar 17 10:25:10 EDT 2014
I think MinRK did something like this here:
His NotebookLoader class does loop over the cells.
On 15 March 2014 11:18, Patrick Surry <patrick.surry at gmail.com> wrote:
> What about a "loop delimiter" magic where you insert a matching pair of
> %magics bracketing a sequence of regular cells, and then it basically
> unrolls the loop for you?
> i.e. when you run the magic, on the first loop iteration it executes each
> cell in place, with the first loop value, and for each subsequent
> iterations, it appends a copied sequence of new cells after the %end,
> evaluated with the corresponding loop element. So if you looped over a
> list of two items, you'd end up with a second copy of all your looped cells
> that have been executed with the second item in the list. (see example
> sketch below)
> So it's doing a kind of repeated block copy & paste (useful in it's own
> right), unrolling the loop, and leaving you the new results to explore and
> further tweak. Maybe it would also mark itself as executed somehow
> (comment itself out?!) so the notebook is stable if you re-execute all
> You'd rapidly want multi-cell delete I guess :) Perhaps other bracketing
> magics like %block cut / %endblock / %block paste ??
> Example with cells a, b, c:
> %begin for item in [1,2]
> when executed becomes:
> # %begin for item in [1, 2]
> a [item=1]
> b [item=1]
> c [item=1]
> # %end
> a [item=2]
> b [item=2]
> c [item=2]
> From: Thomas Kluyver <takowl at gmail.com>
> >On 14 March 2014 09:46, Nikolas Tezak <ntezak at stanford.edu> wrote:
> > I've been thinking about this for a while as well. Although this doesn't
> > quite address looping, I think one idea might be to use cell tags to
> > certain "run sets" of cells and then have a little widget/ui component
> > allows for selecting and running all cells of a certain tag. So, in that
> > respect a good interface for marking/selecting multiple cells and then
> > tagging them or running them or copying them would be great.
> Tags on cells is something that we want to do - there are a lot of useful
> things that could be done with it.
> IPython-dev mailing list
> IPython-dev at scipy.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the IPython-dev