Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update doctest per review
  • Loading branch information
cmaloney committed Feb 5, 2025
commit bf00f334a6264b874a52b1d16b1f5cd85d17a615
20 changes: 11 additions & 9 deletions Doc/library/stdtypes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2859,15 +2859,17 @@ objects.
... del ba[size:]
... else:
... ba += b'\0' * (size - len(ba))
>>>
>>> shrink = bytearray(5)
>>> resize(shrink, 0)
>>> shrink
bytearray(b'')
>>> grow = bytearray(2)
>>> resize(grow, 7)
>>> grow
bytearray(b'\x00\x00\x00\x00\x00\x00\x00')

Examples:

>>> shrink = bytearray(b'abc')
>>> shrink.resize(1)
>>> (shrink, len(shrink))
(bytearray(b'a'), 1)
>>> grow = bytearray(b'abc')
>>> grow.resize(5)
>>> (grow, len(grow))
(bytearray(b'abc\x00\x00'), 5)

.. versionadded:: next

Expand Down