Suppose I want to add some custom behavior to a file object, such as returned by open()
. According this answer, there is (or was) no single base type for all file-like objects. Is this really still true? How about io.IOBase
, or one of its subclasses, as suggested here? Or perhaps by now there is an abstract base class that I could use?
I have already looked at this question, but (besides being quite old) the issues there are about customizing the close()
method (best done with a context manager). So this does not answer my question (and please don't mark this question as a duplicate of it!).