Y
Yin
I've created a class that reads in and processes a file in the
initializer __init__. The processing is fairly substantial, and thus,
instead of processing the file every time the object is created, I
pickle the object to a file.
In subsequent creations of the object, I implement a test to see
whether the pickled file exists. If it does, then I unpickle the
object.
Unfortunately, the __init__ cannot return this unpickled object.
I've used an auxiliary member function which fixes the problem, but I
would prefer to have the correct object returned at instantiation
rather than returned from the auxiliary member function.
Are there other ways of approaching this problem?
Thanks,
Yin
initializer __init__. The processing is fairly substantial, and thus,
instead of processing the file every time the object is created, I
pickle the object to a file.
In subsequent creations of the object, I implement a test to see
whether the pickled file exists. If it does, then I unpickle the
object.
Unfortunately, the __init__ cannot return this unpickled object.
I've used an auxiliary member function which fixes the problem, but I
would prefer to have the correct object returned at instantiation
rather than returned from the auxiliary member function.
Are there other ways of approaching this problem?
Thanks,
Yin