Steven D'Aprano <st...@pearwood.info> writes: > from io import TextIOWrapper > class MyFile(TextIOWrapper): > pass > > but how do I tell open() to use MyFile?
I haven't used it, but does the ‘opener’ parameter do what you want? open(file, mode='r', buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None) -> file object […] A custom opener can be used by passing a callable as *opener*. The underlying file descriptor for the file object is then obtained by calling *opener* with (*file*, *flags*). *opener* must return an open file descriptor (passing os.open as *opener* results in functionality similar to passing None). -- \ “Our products just aren't engineered for security.” —Brian | `\ Valentine, senior vice-president of Microsoft Windows | _o__) development | Ben Finney -- https://mail.python.org/mailman/listinfo/python-list