Python Glossary Русский

all Python 3unicodedatafunction

unicodedata.mirrored()

character properties

Tells whether a character is mirrored in right-to-left text: 1 for brackets and angle quotes, 0 for letters.

Syntax

unicodedata.mirrored(chr, /)

It returns an int, not a bool: 1 or 0, so printing shows digits rather than True/False. It does not mirror anything itself; it only says that in right-to-left output '(' is drawn as ')'. The mirror partner of a character is not stored in unicodedata at all.

Examples

import unicodedata
print(unicodedata.mirrored('('), unicodedata.mirrored('«'), unicodedata.mirrored('a'))  # → 1 1 0
print(type(unicodedata.mirrored('(')).__name__)  # → int

See also

Open in the full glossarydocs.python.orgReport an inaccuracy