[IPython-dev] Highlight lines of code in code cells?

Gabriel Becker gmbecker at ucdavis.edu
Mon Dec 2 20:41:40 EST 2013


Unless I completely miss my guess, shell.history_manager is going to look
at the code that has been executed. This is related to what is in the
cells, of course, but it isn't the same.

Also, the concept of "cell number" if I am correct in assuming you are
referring to the numbers that appear next code cells after the run, is that
they are not persistently connected to current cell content and don't have
a 1-to-1 correspondence to the actual cells during non-headless execution.

i.e. if a code cell is executed, then edited and executed again, but the
cell number targeted for diffing isn't changed, a magic using
shell.history_manager will grab the contents of the cell *when it was run
the first time*, as opposed to what I think is conceptually intended, which
is what is in the cell now.

The metadata tag/JS extension approach can look at the actual contents of
any cell at any time, though I'm not claiming it is without its own
drawbacks.

~G


On Mon, Dec 2, 2013 at 4:22 PM, Mark Voorhies <mark.voorhies at ucsf.edu>wrote:

> On 12/02/2013 04:10 PM, Gabriel Becker wrote:
> > On Mon, Dec 2, 2013 at 3:54 PM, Mark Voorhies <mark.voorhies at ucsf.edu
> >wrote:
> >
> >> On 12/02/2013 03:19 PM, Greg Wilson wrote:
> >>
> >>> Thanks,
> >>> Greg
> >>
> >> Just started fiddling with this, using rmagic.py and cythonmagic.py as
> >> references.
> >>
> >> Can anyone point me at documentation for getting at retrieving cell
> >> content by
> >> number and/or tag via the IPython shell instance?
> >>
> >
> > I could be entirely off base here, but my understanding is that the
> IPython
> > kernel (which provides the magics) used by the notebook doesn't have any
> > concept of cells/the whole notebook in the way you are going to need
> them.
>
> Looks like shell.history_manager.get_range works for cell numbers
> (and that the "tags" that Greg mentioned aren't yet implemented).
>
> --Mark
>
>
> _______________________________________________
> IPython-dev mailing list
> IPython-dev at scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-dev
>



-- 
Gabriel Becker
Graduate Student
Statistics Department
University of California, Davis
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20131202/272225b7/attachment.html>


More information about the IPython-dev mailing list