def is_pickleable(x): try: cPickle.dumps(x, protocol=cPickle.HIGHEST_PROTOCOL) return True except cPickle.PickleError: return False