There are several ways to send a variable value to the body of an Ipython display javascript function that is subject to change:
Example:
from IPython.display import Javascript
var = 5
js_code = """
var x = {};
console.log(x);
""".format(var)
Javascript(js_code)
Example:
from IPython.display import Javascript
var = 5
js_code = """
var x = """ + str(var) + """;
console.log(x);
"""
Javascript(js_code)
Example:
from IPython.display import Javascript
var = 5
js_code = f"""
var x = {var};
console.log(x);
"""
Javascript(js_code)
All of these approaches allow you to send a variable value to the body of an Ipython display javascript function that is subject to change.
Asked: 2021-12-07 11:00:00 +0000
Seen: 9 times
Last updated: Jun 21 '22