all Python 3Byte sequencesfunction
bytes.istitle
bytes — is* checks
Check that the bytes are title-cased.
Syntax
b.istitle(...)
The rule is: every cased letter must be upper-case when preceded by a non-letter and lower-case when preceded by a letter. That produces surprises around separators: b'Hello2World' is title-cased (the digit starts a new "word"), while b"Don't" is not, because the apostrophe breaks the word and istitle() expects b"Don'T" — which is exactly what .title() produces. Using it to validate human names or headlines is a bad idea.
Examples
print(b'Hello World'.istitle()) # → True
print(b'hello world'.istitle()) # → False
print(b'HELLO WORLD'.istitle()) # → False
print(b'Hello2World'.istitle()) # → True
print(b''.istitle()) # → False
print(b'hello world'.title()) # → b'Hello World'
See also
Open in the full glossarydocs.python.orgReport an inaccuracy