Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move around example in to_bytes() to avoid confusion #101595

Merged
merged 4 commits into from
Mar 5, 2023
Merged
Changes from all commits
Commits
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
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