On this page
  1. io.TextIOWrapper
  2. Import
  3. Signature & Overview
  4. Methods & Attributes
  5. Usage
  6. Gotchas
  7. REPL Inspect

io.TextIOWrapper

Prev: io.TextIOBase | Up: io | Next: io.UnsupportedOperation
Rel: io.BlockingIOError, io.BufferedIOBase, io.BufferedRandom, io.BufferedReader
Ref: docs.python.org — io.TextIOWrapper
Tags: #public #python3 #stdlib #io


Import

import io
from io import TextIOWrapper

Signature & Overview

io.TextIOWrapper(buffer, encoding=None, errors=None, newline=None, line_buffering=False, write_through=False)

Character and line based layer over a BufferedIOBase object, buffer.

Methods & Attributes

Usage

import io

raw = io.BytesIO("café\n".encode("utf-8"))
text = io.TextIOWrapper(raw, encoding="utf-8")
assert text.read() == "café\n"
text.detach()   # release raw without closing it
assert not raw.closed

Gotchas

REPL Inspect

from io import TextIOWrapper
help(TextIOWrapper)

Linked from

Related notes