Friends, I really need your help. Using Python and JS in Jupyter ran into a very big (for me) problem:

How to save the result of JS into a variable, and not display it in Out [...]

Code example:

from IPython.display import Javascript from IPython.display import display from IPython.display import HTML js_test = """ var a = 2; var b= 2; var c = a+b; element.text(c); """ Res=Javascript(js_test) 

I need to convert Res to a variable and get "4". If Res is simply assigned to another variable, then I get "IPython.core.display.Javascript"

I would be very grateful for the help. Right very, very!

  • one
    MaxU, EARNED. In general, thank you so much for responding quickly. - Eugene
  • Your decision may be useful to others if you issue it as an answer and indicate the code in it;) - MaxU
  • @MaxU, thanks for the answer! Of course, I will show in the answer a piece of code that has successfully worked. But I really want to make the code more flexible. For example, it will be interesting how to get the data from the "Res" variable from my example without the display function? If so, the example will become more versatile to use. - Eugene

0