[IPython-User] %%javascript and %%svg

Thomas Kluyver takowl@gmail....
Thu Aug 16 09:27:08 CDT 2012

On 16 August 2012 14:58, Benjie Chen <benjie@ginkgobioworks.com> wrote:
> Is there a way to evaluate them dynamically? I'd like to have a piece
> of python code output %%javascript or %%svg. Is there a magic like
> %eval that evaluates these outputs? Or is there another way for the
> python code to inject javascript or svg code?

Yes, the cell magics are just shorthands.

For quick use:

from IPython.core.display import Javascript, SVG

For more object-oriented code, you can give any object
_repr_javascript_ or _repr_svg_ methods. And there are other
possibilities like png and latex.

Hope that helps,

More information about the IPython-User mailing list