all Python 3Byte sequencesfunction
bytes.isalpha
bytes — is* checks
Check that all bytes are ASCII letters and non-empty.
Syntax
b.isalpha(...)
Each byte is checked against A-Z and a-z only, so any non-Latin text run through .encode() comes back False — its UTF-8 bytes are above 127. If you mean letters in general rather than ASCII letters, decode to str first and call str.isalpha.
Examples
print(b'abc'.isalpha()) # → True
print(b'Hello'.isalpha()) # → True
print(b'abc1'.isalpha()) # → False
print(b'hi there'.isalpha()) # → False
print(b''.isalpha()) # → False
print('привет'.encode().isalpha()) # → False
See also
Open in the full glossarydocs.python.orgReport an inaccuracy