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
\wmatches in a Pythonrepattern on astr:py_isalnum_charor_. - 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 Pythonreidentifier pattern. - py_
isalnum - Python
s.isalnum(): not empty and every character a letter or number. - py_
isalnum_ char str.isalnumfor 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.isalphafor one character: a letter (category L*).- py_
isdecimal_ char str.isdecimalfor one character: a decimal digit (category Nd), what\dmatches in a Pythonrepattern.- py_
isspace - Python
s.isspace(): not empty and every character whitespace. - py_
isspace_ char str.isspacefor one character.- py_
lstrip - Python
s.lstrip(). - py_
rstrip - Python
s.rstrip(). - py_
strip - Python
s.strip()(no argument): stripspy_isspace_charcharacters from both ends.