Re: storing variables *in* the notebook
"Loper, Jackson" <[email protected]> Thu, 26 Jan 2017 14:57:34 -0500
| Newsgroups | gmane.comp.python.ipython.devel |
|---|---|
| Message-ID | <CAP8T2V+BUuVX17Yw9kgOvULCjxRXSazX2EqvYuR3N9MC3pt2OQ@mail.gmail.com> |
Zoltán -- I am very curious to know why you want the data embedded in the ipynb file, instead of storing a file in the same directory. Is it so you can share files with colleagues? If so, why not just share the whole directory? Is it just too bulky? Just curious as to what your motivation is. Anywho, if you really want to do it, and you're in the mood, I think it would be fairly straightforward to make a combined python/javascript plugin that allowed one to conveniently store code cells of the form # This is a datacell. If you do not have the datacell javascript extension, # this code cell may look really really long. Sorry about that. x = pickle.loads(b"\x80\x03}q\x00(X\x07\x00\x00\x00Purposeq\x01X$\x00\x00\x00Very important data just for Kluyverq\x02X\x07\x00\x00\x00Contentq\x03X\r\x00\x00\x00You're great!q\x04u.") and make them appear in the notebook as a "data cell" that looks like x = pickle.loads(<<<content abridged>>>) Such a data cell would be uneditable, but could be executed. I think the simplest way to do this would be to design an ipython widget that, when it comes online, adds such a "data cell" directly after the current one. Creating a cell should then be as simple as datacells.make_data_cell(varname='x',data="Hello world.") I could be missing something that makes this utterly impossible though. Cheers! Jackson Loper Division of Applied Math Brown University _______________________________________________ IPython-dev mailing list [email protected] https://mail.scipy.org/mailman/listinfo/ipython-dev