import imp
filehandler = open('imports.pkl', 'rb')
d = pickle.load(filehandler)
filehandler.close()

def reload_class(module_name, class_name):
    mod = __import__(module_name, fromlist=[class_name])
imp.reload(mod)
return getattr(mod, class_name)
if 'class' in d and 'module' in d:
    imp.reload(__import__(d['module']))
ClassExample = reload_class(d['module'], d['class'])
How do I pickle a dictionary containing a module & class?