bytes.istitle() returns True if the data contains at least one ASCII letter, every uppercase letter follows a non-letter (or starts the data), and every lowercase letter follows a letter.
In other words, each word must look like Word. It uses the same word rule as title(), so data.title().istitle() is True for any data that contains a letter.
bytes.istitle() is a method of the built-in bytes type: call it on a bytes object with dot notation, such as data.istitle(...). No import is needed, and bytearray objects have the same method.
Syntax
No arguments; returns a bool.
python
result = data.istitle()
Call
What it does
b"Hello World".istitle()
Returns True.
b"Hello world".istitle()
Returns False.
b"Content-Type".istitle()
Returns True.
All-uppercase words such as b"HTTP" are not title case: the T after H is uppercase but follows a letter.
Method signatures
python
bytes.istitle()
# returns True or False; bytearray.istitle() works the same way
Parameters
istitle() takes no parameters.
Return Value
Return Value
Description
True
Title-cased ASCII words, with at least one letter.
False
Any word breaks the rule, or there are no ASCII letters.
Python Examples
Example 1 — Which Byte Strings Are Title Case?
Test a title, a sentence, an acronym, a header name, and a number.
python
for s in [b"Hello World", b"Hello world", b"HELLO", b"Content-Type", b"123"]:
print(s, s.istitle())
Inner capital fails. In McDonald, the D follows a letter, so it is not title case.
title() flattens it. Both spellings become b'Mcdonald', which passes the check.
Apostrophe breaks words.title() capitalizes the N after the apostrophe, and the repr switches to double quotes because the result contains '.
Example 3 — Accented Words as Text and as Bytes
The French word for school starts with an accented capital. Compare the str check, its UTF-8 bytes, and a byte string where the first ASCII letter is uppercase.
python
word = "\u00c9cole"
print(word.istitle())
print(word.encode("utf-8").istitle())
print(b"\xc3\x89Cole".istitle())
Output
True
False
True
How It Works
str is correct. U+00C9 is an uppercase letter followed by lowercase ones.
bytes miss the capital. The accent bytes are not letters, so c looks like the start of a word and is lowercase.
ASCII capital after the bytes. With an uppercase C after the non-ASCII bytes, the bytes rule is satisfied.
Frequently Asked Questions
That every run of ASCII letters starts with an uppercase letter followed only by lowercase letters, and that there is at least one letter.
The T, T, and P are uppercase but follow a letter. Title case allows only one capital at the start of each word.
Yes. Any non-letter byte separates words, so b"Content-Type".istitle() is True.
Yes, whenever the data contains at least one ASCII letter.
Not on bytes. Decode to str and use str.istitle().