On this page
  1. bytearray
  2. Import & Availability
  3. Overview & Signature
  4. Common Methods & Attributes
  5. Usage
  6. Gotchas
  7. REPL Inspect

bytearray

Prev: breakpoint | Up: __builtins__ | Next: bytes
Rel: bool, int, float, complex, str
Ref: docs.python.org — bytearray
Tags: #public #python3 #builtins


Import & Availability

# Built-in (available globally without import)
from builtins import bytearray

Overview & Signature

bytearray(iterable_of_ints) -> bytearray

bytearray(string, encoding[, errors]) -> bytearray bytearray(bytes_or_buffer) -> mutable copy of bytes_or_buffer bytearray(int) -> bytes array of size given by the parameter initialized with null bytes

Common Methods & Attributes

Usage

buf = bytearray(b"hello")
buf[0] = ord("H")
buf.extend(b" world")
assert bytes(buf) == b"Hello world"

Gotchas

REPL Inspect

help(bytearray)

Linked from

Related notes