[IPython-User] Python code in a markdown cell
Thu Apr 12 23:11:15 CDT 2012
On Mon, Apr 9, 2012 at 3:36 PM, Michael Hadmack <firstname.lastname@example.org> wrote:
> Is there a way that you can execute python code from within a markdown cell?
> For example I want to refer to the value a result from an earlier python
> cell from within my markdown text. Presently I just copy and paste but I
> would like to do this dynamically. Really what I suppose is needed is a new
> markdown tag that will pass the contents to IPython.display() via
You actually can execute Python code in the kernel, try the following
in a markdown cell:
then print x in your next python cell, and you'll see 99 (also note
how your prompt counter will have gone up by one).
Now, the JS api doesn't expose direct retrieval of individual
variables, so pulling back variables from python to be rendered into
your markdown isn't currently possible. We've thought a bit about
that, because the need is fairly obvious to write paragraphs with nice
references to previous computations. But we don't have a clean
solution to the problem yet.
More information about the IPython-User