[3.11] Move around example in to_bytes() to avoid confusion (GH-101595) (#102434)

Move around example in to_bytes() to avoid confusion (GH-101595)

Moves an example to be closer to the sentence that refers to it.
(cherry picked from commit 5da379ca7d)

Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
This commit is contained in:
Miss Islington (bot) 2023-03-05 01:42:36 -08:00 committed by GitHub
parent f96907a67c
commit caff048cb3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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):