Posts/Pages Can Now Have Editable Python Code
Check this out:
print("hello, world")
a = 3
b = 5
print(a+b)
Go head, edit that code and click run. You have all the default anaconda packages available to you (sympy, numpy, etc).
How Is This Being Done?
We are using Thebelab
. To make a post/page be able to have editable code, give it the live_code: true
front matter variable. Then, within that page, give the HTML element that have your code the data-executable="true"
attribute.
My posts/pages are usually written in markdown, which is then converted to HTML. Here is how to add the data-executable="true"
to a markdown code element:
~~~
# some python code...
~~~
{: data-executable="true"}