Skip to main content

Module pytext

Module pytext 

Source
Expand description

Python’s character tests, exactly: str.isalpha, str.isalnum and str.isspace of Python 3.13 (Unicode 15.1), which Localization OS uses for its “has a letter or digit” and whitespace rules.

Rust’s char::is_alphanumeric and friends follow a newer Unicode and differ: they count combining marks (U+0301, U+0903, …) and Unicode 16 letters as alphanumeric where Python does not, and is_whitespace leaves out U+001C..U+001F, which Python treats as whitespace. A format crate that must skip or keep the same values as Localization OS calls these instead. The tables come from tools/gen_pytables.py.

Functions§

py_has_alnum
Python any(ch.isalnum() for ch in s): the string has a letter or digit anywhere. This is the usual “does this value carry text” test; combining marks, punctuation and symbols alone do not count.
py_has_alpha
Python any(ch.isalpha() for ch in s).
py_is_word_char
What \w matches in a Python re pattern on a str: py_isalnum_char or _.
py_is_word_start_char
What [^\W\d] matches: a word character that is not a decimal digit (a letter, _, or a number such as a superscript or roman numeral). The first character of a Python re identifier pattern.
py_isalnum
Python s.isalnum(): not empty and every character a letter or number.
py_isalnum_char
str.isalnum for one character: a letter or a number (decimal, digit or numeric).
py_isalpha
Python s.isalpha(): not empty and every character a letter.
py_isalpha_char
str.isalpha for one character: a letter (category L*).
py_isdecimal_char
str.isdecimal for one character: a decimal digit (category Nd), what \d matches in a Python re pattern.
py_isspace
Python s.isspace(): not empty and every character whitespace.
py_isspace_char
str.isspace for one character.
py_lstrip
Python s.lstrip().
py_rstrip
Python s.rstrip().
py_strip
Python s.strip() (no argument): strips py_isspace_char characters from both ends.