Python Glossary Русский

all Python 3unicodedataterm

unicodedata.UCD

Unicode database

The class of a Unicode character database object; its instance unicodedata.ucd_3_2_0 offers the same functions for the old version 3.2.0.

Syntax

unicodedata.ucd_3_2_0.category(chr)

You cannot create an instance (TypeError); the single instance, ucd_3_2_0, serves the idna codec and protocols stuck on Unicode 3.2. The module itself follows unicodedata.unidata_version, which grows with every Python release (14.0.0 in 3.11, 16.0.0 in 3.14), so category() of a new emoji differs between Pythons. Ordinary code does not need UCD; call the module functions.

Examples

import unicodedata
old = unicodedata.ucd_3_2_0
print(type(old) is unicodedata.UCD, old.unidata_version)  # → True 3.2.0
print(old.category('😀'), unicodedata.category('😀'))  # → Cn So — в 3.2 эмодзи ещё не было
print(unicodedata.unidata_version)  # → ? 16.0.0 — зависит от версии Python
import unicodedata
unicodedata.UCD()  # → TypeError: cannot create 'unicodedata.UCD' instances

See also

Common errors

Open in the full glossarydocs.python.orgReport an inaccuracy