how to display python variable in markdown?

4,719 views
Skip to first unread message

Andy Davidson

unread,
Aug 31, 2016, 7:08:42 PM8/31/16
to jup...@googlegroups.com
Is there way to display python variables in markdown?

In R-Studio using knitter you would do the following


Display a variable previously defined `r myLocalVar` blah blah blah

The results I found googling seemed to be out of date

Thanks

Andy

Sylvain Corlay

unread,
Aug 31, 2016, 7:31:14 PM8/31/16
to jup...@googlegroups.com
Hi Andy,

You can use ipywidgets to do this. First, display a markdown cell with a div having a specific selector

```
# This is markdown

## An empty div with class `foobar`

<div class='foobar'></div>
```

Then insert a view of a Jupyter widget inline in the div

```
from ipywidgets import *
slider = IntSlider(description='Slider')
PlaceProxy(child=slider, selector='.foobar')
```

You can do this with any widget like a Label, slider or even a bqplot / pythreejs / ipyleaflet visualization.

Cheers,

Sylvain

--
You received this message because you are subscribed to the Google Groups "Project Jupyter" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jupyter+unsubscribe@googlegroups.com.
To post to this group, send email to jup...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jupyter/D3ECB17D.4583D%25Andy%40SantaCruzIntegration.com.
For more options, visit https://groups.google.com/d/optout.

Andy Davidson

unread,
Aug 31, 2016, 7:41:46 PM8/31/16
to jup...@googlegroups.com
Thanks Sylvain

Andy

To unsubscribe from this group and stop receiving emails from it, send an email to jupyter+u...@googlegroups.com.

To post to this group, send email to jup...@googlegroups.com.

Bjarke Dalslet

unread,
Sep 1, 2016, 1:01:04 AM9/1/16
to Project Jupyter
There is a nice set of extension on github:

https://github.com/ipython-contrib/jupyter_contrib_nbextensions

I think the Python-markdown extension does exactly what you want.

- Bjarke

Hai Nguyen

unread,
Sep 2, 2016, 11:49:07 PM9/2/16
to jup...@googlegroups.com
On Wed, Aug 31, 2016 at 7:31 PM, Sylvain Corlay <sylvain...@gmail.com> wrote:
Hi Andy,

You can use ipywidgets to do this. First, display a markdown cell with a div having a specific selector

```
# This is markdown

## An empty div with class `foobar`

<div class='foobar'></div>
```

Then insert a view of a Jupyter widget inline in the div

```
from ipywidgets import *
slider = IntSlider(description='Slider')
PlaceProxy(child=slider, selector='.foobar')
```


Oh, I like this very much. thanks

Hai
Reply all
Reply to author
Forward
0 new messages