On Tue, Nov 23, 2010 at 10:25 PM, Éric Araujo
Hi,
Recently I had the need to filter objects based on whether they're picklable or not:
http://stackoverflow.com/questions/4080688/python-pickling-a-dict-with-some-...
I'm not sure what's a good way to check for a specific object whether
it's
picklable.
< http://stackoverflow.com/questions/4080688/python-pickling-a-dict-with-some-... This led me to think: Maybe we should have an `Unpicklable` abstract base class in the `collections` module? Then various unpicklable classes, like locks, files or widgets, could inherit from this class to signify that they cannot be pickled.
What do you think?
This sounds useful. I’d rather spell the ABC pickle.Picklable, though.
Regards
(Spelling note: People told me that "pickleable" (with an "e" in the middle) makes more sense, so I'm using that now.) The best solution might be to have both a `Pickleable` class and an `Unpickleable` class. The reason to have the former is that `isinstance(thing, Pickleable)` is more natural, and the reason to have the latter is because we can't require people to inherit from `Pickleable` for every single class that they define. (Since pickleability is the rule and unpickleability is the exception.) So `Pickleable` could have a `__subclasshook__` that would do the real work, similarly to `Iterable`. Ram. -- Sincerely, Ram Rachum