all Python 3Byte sequencesfunction
bytearray.upper
bytearray — case
Return a copy with ASCII letters upper-cased.
Syntax
ba.upper(...)
This is a pure ASCII table: any byte outside a-z stays as it is, and unlike C's toupper() the result never depends on the system locale. A fresh bytearray comes back and the original is untouched; comparing it to a bytes literal works fine, because bytearray and bytes compare by content rather than by type.
Examples
print(bytearray(b'abc').upper()) # → bytearray(b'ABC')
print(bytearray(b'Hello, World! 42').upper()) # → bytearray(b'HELLO, WORLD! 42')
print(bytearray(b'caf\xc3\xa9').upper()) # → bytearray(b'CAF\xc3\xa9')
print(bytearray(b'Yes').upper() == b'YES') # → True
ba = bytearray(b'abc')
print(ba.upper(), ba) # → bytearray(b'ABC') bytearray(b'abc')
See also
Open in the full glossarydocs.python.orgReport an inaccuracy