PyDocs

Nav

Generic Operating System Services

TextIOWrapper

io

class
  • TextIOWrapper(buffer, encoding=None, errors=None, newline=None, line_buffering=False, write_through=False)
Character and line based layer over a BufferedIOBase object, buffer.

encoding gives the name of the encoding that the stream will be
decoded or encoded with. It defaults to locale.getencoding().

errors determines the strictness of encoding and decoding (see
help(codecs.Codec) or the documentation for codecs.register) and
defaults to "strict".

newline controls how line endings are handled. It can be None, '',
'\n', '\r', and '\r\n'.  It works as follows:

* On input, if newline is None, universal newlines mode is
  enabled. Lines in the input can end in '\n', '\r', or '\r\n', and
  these are translated into '\n' before being returned to the
  caller. If it is '', universal newline mode is enabled, but line
  endings are returned to the caller untranslated. If it has any of
  the other legal values, input lines are only terminated by the given
  string, and the line ending is returned to the caller untranslated.

* On output, if newline is None, any '\n' characters written are
  translated to the system default line separator, os.linesep. If
  newline is '' or '\n', no translation takes place. If newline is any
  of the other legal values, any '\n' characters written are translated
  to the given string.

If line_buffering is True, a call to flush is implied when a call to
write contains a newline character.
Changed in 3.3, 3.10
  • 3.3: The write_through argument has been added.
  • 3.3: The default encoding is now locale.getpreferredencoding(False) instead of locale.getpreferredencoding(). Don’t change temporary the locale encoding using locale.setlocale(), use the current locale encoding instead of the user preferred encoding.
  • 3.10: The encoding argument now supports the "locale" dummy encoding name.
Members of TextIOWrapper

l

line_buffering
Whether line buffering is enabled.

r

reconfigure
Reconfigure the text stream with new parameters.

s

seek
Set the stream position, and return the new stream position.

t

tell
Return the stream position as an opaque number.

w

write_through
Whether writes are passed immediately to the underlying binary buffer.
0 Examples
No examples for io/TextIOWrapper.
See Also
No see-alsos for io/TextIOWrapper
0 Notes
No notes for TextIOWrapper