Bytearray Methods
bytearray.pop()
Remove and return the byte at the requested index. Without an index, remove the last byte. Negative indices count from the end. Returns an integer rather than a bytes or bytearray object. An empty buffer or out-of-range index raises IndexError; very large indices can fail integer-index conversion. Removing an existing byte requires shrinking, which is blocked by active exports.
Formal Syntax & Structure
python syntaxpython
data.pop(index=-1, /)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| index | int | SupportsIndex | Index of byte to remove; defaults to last byte. |
Return Value
int
Removed integer byte value (0–255).
Working Example
Example Snippetpython
data = bytearray(b"ABC")print(data.pop())print(data.pop(0))print(data)