Python bytes.isupper() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
bytes method

Definition

bytes.isupper() returns True if the bytes contain at least one ASCII uppercase letter and no ASCII lowercase letters. Digits, spaces, punctuation, and bytes 128-255 are ignored.

Many text protocols write keywords in capitals, such as USER, PASS, and QUIT in FTP. isupper() helps tell those keywords apart from user data.

bytes.isupper() is a method of the built-in bytes type: call it on a bytes object with dot notation, such as data.isupper(...). No import is needed, and bytearray objects have the same method.

Syntax

No arguments; returns a bool.

python
result = data.isupper()
CallWhat it does
b"HTTP/1.1".isupper()Returns True.
b"Error".isupper()Returns False.
b"42".isupper()Returns False: no letters.

isupper() and islower() can both be False, for mixed case or for data without letters, but never both True.

Method signatures
python
bytes.isupper()
# returns True or False; bytearray.isupper() works the same way

Parameters

isupper() takes no parameters.

Return Value

Return ValueDescription
TrueAt least one ASCII uppercase letter and no ASCII lowercase letters.
FalseAny lowercase letter, or no ASCII letters at all.

Python Examples

Example 1 — Uppercase Checks with Digits and Symbols

Check a protocol version, an error code, a mixed-case word, a number, and empty bytes.

python
for s in [b"HTTP/1.1", b"ERROR 42", b"Error", b"42", b""]:
    print(s, s.isupper())

How It Works

  1. Symbols ignored. The slash, dot, and digits in HTTP/1.1 do not matter.
  2. Lowercase letters fail. rror makes b"Error" return False.
  3. No letters, no pass. b"42" and empty bytes return False.

Example 2 — A Lowercase Accent That bytes Ignore

The str check sees the lowercase accented letter; the bytes check only sees the ASCII T.

python
word = "\u00e9T\u00c9"

print(word.isupper())
print(word.encode("utf-8").isupper())
print(word.encode("utf-8"))

How It Works

  1. str is strict. U+00E9 is lowercase, so the text is not all uppercase.
  2. bytes ignore it. Only the ASCII T counts, and it is uppercase.
  3. Look at the bytes. The repr shows the two accented letters as escape pairs around the T.

Example 3 — Find Keywords in an FTP-Style Session

Split a session line into tokens and keep the uppercase keywords, then confirm one is all letters.

python
tokens = b"USER ada PASS Secret1 QUIT".split()

print([t for t in tokens if t.isupper()])
print(b"QUIT".isupper() and b"QUIT".isalpha())

How It Works

  1. Keywords kept. USER, PASS, and QUIT are all uppercase.
  2. Data dropped. ada is lowercase and Secret1 is mixed case.
  3. Combine checks. Adding isalpha() rules out tokens with digits or symbols.

Frequently Asked Questions

That there is at least one ASCII uppercase letter and no ASCII lowercase letter.
No. b"ABC123".isupper() is True; only letters matter.
There are no letters, and at least one uppercase letter is required.
No. Non-ASCII bytes are ignored.
Use data.upper().

Next: bytes.join()

Concatenate an iterable of bytes-like objects with this bytes as the separator.

join() →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

15 people found this page helpful