Skip to content

Commit

Permalink
Move around example in to_bytes() to avoid confusion (python#101595)
Browse files Browse the repository at this point in the history
Moves an example to be closer to the sentence that refers to it.
  • Loading branch information
skirpichev authored and hugovk committed Mar 6, 2023
1 parent 5a078fc commit dde16c4
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Doc/library/stdtypes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -530,12 +530,14 @@ class`. In addition, it provides a few more methods:
is ``False``.

The default values can be used to conveniently turn an integer into a
single byte object. However, when using the default arguments, don't try
to convert a value greater than 255 or you'll get an :exc:`OverflowError`::
single byte object::

>>> (65).to_bytes()
b'A'

However, when using the default arguments, don't try
to convert a value greater than 255 or you'll get an :exc:`OverflowError`.

Equivalent to::

def to_bytes(n, length=1, byteorder='big', signed=False):
Expand Down

0 comments on commit dde16c4

Please sign in to comment.