Re: storing variables *in* the notebook
Kiko <[email protected]> Fri, 27 Jan 2017 17:53:10 +0100
| Newsgroups | gmane.comp.python.ipython.devel |
|---|---|
| Message-ID | <CAB-sx60xhTrZav+5u0pAsZ=BkrKUrsBVd3aHiMS=J04FGsNzwQ@mail.gmail.com> |
2017-01-27 16:16 GMT+01:00 Kiko <[email protected]>: > > >>> >> I can't tell why, but somehow this idea seems a bit familiar to me... >> >> Aha. > > Ok, I read the thread diagonally and my2cents ideas are already there... > > Sorry for the noise :-P > An example about how to write to your metadata. This should provide some hints to create a line magic to do so: from IPython.display import Javascript x = [1,2,3] def add_metadata(var_name, var): js = """ if (Jupyter.notebook.metadata['stored'] === undefined){{Jupyter.notebook.metadata['stored'] = {{}}}} Jupyter.notebook.metadata['stored']['{var_name}']={var_content_serialised} """ return Javascript(js.format(var_name=var_name, var_content_serialised=var.__repr__())) add_metadata('x', x) _______________________________________________ IPython-dev mailing list [email protected] https://mail.scipy.org/mailman/listinfo/ipython-dev