Returning a custom file object (Python 3)

Steven D'Aprano steve at pearwood.info
Wed May 27 22:16:12 EDT 2015


I'd like to return a custom file object, say my own subclass. I can easily
subclass the file object:


from io import TextIOWrapper
class MyFile(TextIOWrapper):
    pass


but how do I tell open() to use MyFile?


Answers for Python 3, thanks.




-- 
Steven




More information about the Python-list mailing list