Understanding namespace when using Javascript from Ipython.core.display in Jupyter Notebook -


i having trouble understanding namespace of javascript function provided in ipython.

from ipython.core.display import display, javascript display(javascript(u""" var variable = 'hello' console.log(variable) """)) [output] hello 

the above seems work fine, following throws error.

display(javascript(u""" var variable = 'hello' """)) display(javascript(u""" console.log(variable) """)) [output] javascript error adding output! referenceerror: variable not defined see browser javascript console more details. 

if want save data variable in 1 function, ajax call, , use function in separate cell later in jupyter notebook, best practice method doing this? current implementation uses window store variable.

display(javascript(u""" var variable = 'hello' window.variable = variable """)) display(javascript(u""" console.log(window.variable) """)) [output] hello 

another related question - after storing in window, i'm unable access variable javascript console. i'd access javascript console debugging, use best practices going forward. suggestions?

edit :

the following seems work fine.

display(html(u"""  <script> variable='hello' </script> """))  display(html(u"""  <script> console.log(variable) </script> """)) 


Comments

Popular posts from this blog

sql server - Cannot query correctly (MSSQL - PHP - JSON) -

php - trouble displaying mysqli database results in correct order -

C++ Linked List -