[Python-checkins] [3.11] Move around example in to_bytes() to avoid confusion (GH-101595) (#102434)
mdickinson
webhook-mailer at python.org
Sun Mar 5 04:42:45 EST 2023
https://github.com/python/cpython/commit/caff048cb35c9498e95c1e64c507e0c6b7783d7e
commit: caff048cb35c9498e95c1e64c507e0c6b7783d7e
branch: 3.11
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: mdickinson <dickinsm at gmail.com>
date: 2023-03-05T09:42:36Z
summary:
[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 5da379ca7dff44b321450800252be01041b3320b)
Co-authored-by: Sergey B Kirpichev <skirpichev at gmail.com>
files:
M Doc/library/stdtypes.rst
diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst
index 608e15453be8..1fb3931902e4 100644
--- a/Doc/library/stdtypes.rst
+++ b/Doc/library/stdtypes.rst
@@ -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):
More information about the Python-checkins
mailing list