小编wrw*_*rwr的帖子

Unpickling objects after renaming a module

I have a problem loading objects via numpy.load after renaming a module. Here's a simple example showing the problem.

Imagine having a class defined in mymodule.py:

class MyClass(object):
    a = "ciao"
    b = [1, 2, 3]

    def __init__(self, value=2):
        self.value = value
Run Code Online (Sandbox Code Playgroud)

from a python session I can simply create an instance and save it:

import numpy as np
import mymodule

instance = mymodule.MyClass()
np.save("dump.npy", instance)
Run Code Online (Sandbox Code Playgroud)

Loading the file works nicely (even from a fresh session started in the …

python numpy pickle

3
推荐指数
1
解决办法
1287
查看次数

标签 统计

numpy ×1

pickle ×1

python ×1