Re: storing variables *in* the notebook
Klymak Jody <[email protected]> Thu, 26 Jan 2017 13:06:12 -0800
| Newsgroups | gmane.comp.python.ipython.devel |
|---|---|
| Message-ID | <[email protected]> |
> I think this goes far beyond what I had in mind. I think this function or whatever would just be
>
> In [221]: x = long_calculation() # x is 42
> %store_in_notebook x
>
> and in the new session
>
> In [1]: %store_in_notebook -restore_variables
> In [2]: x
> Out [2]: 42
For my taste, I’d just save that result in a file (`pickle` or `shelf`, or netcdf if I wanted to be formal). Its a lot more transparent what is going on.
Imagine this case: I `%store_in_notebook` the results of a long calculation, and then remove that code from the notebook for some reason. I might very well wonder a year from now why my notebook is 50 Gb, and have no documentation of how it got that way.
However, if you do have a whole slew of variables you suddenly want to save, did you try `dill`?
import dill
import numpy as np
filename= 'globalsave.pkl'
if 1:
x = np.arange(20)
dill.dump_session(filename)
else:
dill.load_session(filename)
Cheers, Jody
_______________________________________________
IPython-dev mailing list
[email protected]
https://mail.scipy.org/mailman/listinfo/ipython-dev