I have a list of objects of various types that I want to pickle. I would like to pickle only those which are pickleable. Is there a standard way to check if an object is of
dill allows for pickling more things that the builtin pickle.
dill
pickle
This should do what you what, I think:
def is_picklable(obj): try: pickle.dumps(obj) except pickle.PicklingError: return False return True