-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hickle all defined variables #107
Comments
Simple proof of concept (needs IPython/Jupyter): import hickle as hkl
import numpy as np
hkl.dump(0, 'test.hkl', path="dummy", mode='w')#just to have a file to append to
# Define some variables
a = 1
b = "Hello"
array_obj = np.ones(32768, dtype='float32')
#List variables (types should be extended e.g. to pandas DataFrame..)
var_list = %who_ls int float ndarray str
var_dict = {}
for var in var_list:
var_dict[var] = eval(var)
#Dump defined variables
for k, v in var_dict.items():
hkl.dump(v, 'test.hkl', path=k, mode='a') |
I have looked into this a few times over the past 6 months, but there are many, many different pitholes and other problems to make this work consistently on all three operating systems. |
Ok, I was not aware of these differences in IPython implementations.
|
The |
Unless you want to use inspect.stack and walk call stack up by one level at least i do fear it is not really doable in a portable manner. The easiest would be to call hickle with output of Therefore i do think %who_ls is some magic command specific to IPython kernel which directly interprets this literal and returns the list of variable definitions recorded before. EDIT
And not more is possible as Given this the above example could be changed as follows:
|
As suggested in #28 it would be really useful to dump all the currently defined variables. Optionally they could all go into a single, well structured .hkl file.
As reference here there is an example of user defined variable retrival.
The text was updated successfully, but these errors were encountered: