mirror of
https://github.com/python/cpython.git
synced 2025-10-02 13:22:19 +00:00
[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:
parent
f96907a67c
commit
caff048cb3
1 changed files with 4 additions and 2 deletions
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue