when i use pickle package to serialize a dict object for example, i can load it in another context without problem. but it's not the case for functions unless i import it again as explained here (i don't know if it's feasible in case of functions defined inside notebooks). But why this behaviour?, how function object is different from dict object?
example:
open notebook A, run the following:
def func(x):
return x**2
with open("myfile", "wb") as f:
pickle.dump(func,f)
open notebook B, run the following:
with open("myfile", "rb") as f:
func = pickle.load(f)
this would return
AttributeError: Can't get attribute 'func' on <module '__main__'>