<div dir="ltr"><div class="gmail_quote">On Tue, Nov 23, 2010 at 10:25 PM, Éric Araujo <span dir="ltr"><<a href="mailto:merwok@netwok.org">merwok@netwok.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hi,<br>
<div class="im"><br>
> Recently I had the need to filter objects based on whether they're picklable<br>
> or not:<br>
><br>
> <a href="http://stackoverflow.com/questions/4080688/python-pickling-a-dict-with-some-unpicklable-items" target="_blank">http://stackoverflow.com/questions/4080688/python-pickling-a-dict-with-some-unpicklable-items</a><br>

><br>
> I'm not sure what's a good way to check for a specific object whether it's<br>
> picklable.<br>
><br>
</div>> <<a href="http://stackoverflow.com/questions/4080688/python-pickling-a-dict-with-some-unpicklable-items" target="_blank">http://stackoverflow.com/questions/4080688/python-pickling-a-dict-with-some-unpicklable-items</a>>This<br>

<div class="im">> led me to think: Maybe we should have an `Unpicklable` abstract base class<br>
> in the `collections` module? Then various unpicklable classes, like locks,<br>
> files or widgets, could inherit from this class to signify that they cannot<br>
> be pickled.<br>
><br>
> What do you think?<br>
<br>
</div>This sounds useful.  I’d rather spell the ABC pickle.Picklable, though.<br>
<br>
Regards<br>
<br>
</blockquote></div><div><br></div><div>(Spelling note: People told me that "pickleable" (with an "e" in the middle) makes more sense, so I'm using that now.)</div><br>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.)<div>
<br></div><div>So `Pickleable` could have a `__subclasshook__` that would do the real work, similarly to `Iterable`.</div><div><div><br></div><div><br></div><div>Ram.<br clear="all"><br>-- <br>Sincerely,<br>Ram Rachum<br>

</div></div></div>