title: Jupyter Notebook, Python: How to call a magic from within a function?
body: <p>I am using the Jupyter Notebook, and am trying to create a widget, based on a template found on Github.</p>
  
  <p>The template uses at some point the magic <code>%%javascript</code>. This works fine when directly pasted in the cells of the notebook.</p>
  
  <p>However when I tried to make a function out of the widget, having the <code>%%javascript</code>expression makes it returns the error:   </p>
  
  <p><code>%%javascript SyntaxError: invalid syntax</code></p>
  
  <p>Anyone knows how to "convert" the magic command so that it can be invoked properly from within a function (the function is saved in a separate file) </p>