title: Design of a python pickleable object that describes a file
body: <p>I would like to create a class that describes a file resource and then pickle it.  This part is straightforward.  To be concrete, let's say that I have a class "A" that has methods to operate on a file.  I can pickle this object if it does not contain a file handle.  I want to be able to create a file handle in order to access the resource described by "A".  If I have an "open()" method in class "A" that opens and stores the file handle for later use, then "A" is no longer pickleable.  (I add here that opening the file includes some non-trivial indexing which cannot be cached--third party code--so closing and reopening when needed is not without expense).  I could code class "A" as a factory that can generate file handles to the described file, but that could result in multiple file handles accessing the file contents simultaneously.  I could use another class "B" to handle the opening of the file in class "A", including locking, etc.  I am probably overthinking this, but any hints would be appreciated.</p>