Python Glossary Русский

Python 3.5+deprecated in 3.11typingterm

typing.Text

I/O streams

An alias of str kept for Python 2 compatibility; equals str in Python 3.

Syntax

typing.Text  # == str

Deprecated since Python 3.11: Python 2 is no longer supported, so this alias has lost its purpose. Removal isn't currently planned, but in new code just write str.

Examples

from typing import Text
print(Text is str)   # → True
print(Text.__name__)   # → str
print(Text(42) + '!')   # → 42!
print(isinstance('hello', Text))   # → True
from typing import Text
def shout(s: Text) -> Text: return s.upper()
print(shout('hi'))   # → HI

See also

Open in the full glossarydocs.python.orgReport an inaccuracy