[IPython-dev] storing variables *in* the notebook

Loper, Jackson jackson_loper at brown.edu
Thu Jan 26 14:57:34 EST 2017


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20170126/00071b27/attachment.html>


More information about the IPython-dev mailing list