On Tue, May 24, 2011 at 6:58 PM, Victor Stinner <victor.stin...@haypocalc.com> wrote: > StreamReader, StreamWriter, TextIOWrapper and StreamReaderWriter all > have a file-like API: tell(), seek(), read(), readline(), write(), etc. > The implementation is maybe different, but the API is just the same, and > so the usecases are just the same. > > I don't see in which case I should use StreamReader or StreamWriter > instead TextIOWrapper. I thought that TextIOWrapper is specific to files > on disk, but TextIOWrapper is already used for other usages like > sockets.
Back up a step here. It's important to remember that the codecs module *long* predates the existence of the Python 3 I/O model and the io module in particular. Just as PEP 302 defines how module importers should be written, PEP 100 defines how text codecs should be written (i.e. in terms of StreamReader and StreamWriter). PEP 3116 then defines how such codecs can be used as part of the overall I/O stack as redesigned for Python 3. Now, there may be an opportunity here to rationalise things a bit and re-use the *new* io module interfaces as the basis for an updated codec API PEP, but we shouldn't be hasty in deprecating an old API that is about "how to write codecs" just because it is similar to a shiny new one that is about "how to process I/O data". Cheers, Nick. -- Nick Coghlan | ncogh...@gmail.com | Brisbane, Australia _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com