Your example isn’t a typical ‘pickling’ example. Unpickling an instance involves defining its class by loading the appropriate module (if this module is not already loaded).
For example, define you class in a separate module.
# test.py
print "Defining the class Test"
class Test:
def __init__(self, x):
self.data = "I am Test '%d'" % x
I’ve been working on basically the same thing as a way to get data-structure persistence between script executions. Word to the wise, make sure all the data you intend to pickle is in instance variables rather than class variables or you’re going to have a bad time. Also, cPickle doesn’t seem to be very friendly towards classes of the Rhino.Geometry persuasion. I’ll keep trying but I think this might be because they’re defined in RhinoCommon.