'Using Ipython.display javasript along with interact is producing 2 new code cells instead of one. How do I restrict it to one new code cell?

def func(x, print_func=False, jupyter_used=True):
    code= Some python code would be called using x
    if print_func==False:
       encoded_code=base64.b64encode(str.encode(code))).decode()
       display(Javascript("""
           var code = IPython.notebook.insert_cell_below('code');
                      code.set_text(atob("{0}"));
                      """.format(where, encoded_code)))    
     elif print_function==True:
         print(code)

interact_manual(func,x=func_list, print_func=False, jupyter_used=fixed(True))



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source