#!/usr/bin/env python import sys, os from smtplib import SMTP from pickle import dump,load original__import = __import__ def myimport(name, *args): print("import", repr(name)) return original__import(name, *args) __builtins__.__import__ = myimport # Any object at all in some other module will do here toPickle = SMTP() writeFile = open("dump", "wb") dump(toPickle, writeFile) writeFile.close() os.system("unix2dos dump") readFile = open("dump", "rb") print(load(readFile))