Suppose I had the following subclass that I'm using to temporarily endow
>>> f = MyList()
>>> .. bunch of list stuff ...
I think what you wanted to do is to pickle the class instance and bundle up the class description in the pickled object.
pickle doesn't pickle a class description, but
>>> class MyList(list): ... def some_function(self): ... pass ... >>> f = MyList() >>> import dill >>> dill.dump(f, open('somefile','w')) >>>
And then upon loading, it just works...
dude@hilbert>$ python Python 2.7.12 (default, Jun 29 2016, 12:42:34) [GCC 4.2.1 Compatible Apple LLVM 5.1 (clang-503.0.40)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import dill >>> f = dill.load(open('somefile','r')) >>> f  >>> type(f) <class '__main__.MyList'> >>> g = f.__class__()