https://github.com/python/cpython/commit/273459562e3eaee4dd242fe8ee098cfdb4eebe9b
commit: 273459562e3eaee4dd242fe8ee098cfdb4eebe9b
branch: main
author: Blaise Pabon <[email protected]>
committer: hugovk <[email protected]>
date: 2025-06-13T11:32:07Z
summary:

gh-106318: Add example for `str.encode()` (#134520)

Co-authored-by: Hugo van Kemenade <[email protected]>

files:
M Doc/library/stdtypes.rst

diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst
index b75e5ceecf874e..4854a2c077bb28 100644
--- a/Doc/library/stdtypes.rst
+++ b/Doc/library/stdtypes.rst
@@ -1841,6 +1841,14 @@ expression support in the :mod:`re` module).
    unless an encoding error actually occurs,
    :ref:`devmode` is enabled
    or a :ref:`debug build <debug-build>` is used.
+   For example::
+
+      >>> encoded_str_to_bytes = 'Python'.encode()
+      >>> type(encoded_str_to_bytes)
+      <class 'bytes'>
+      >>> encoded_str_to_bytes
+      b'Python'
+
 
    .. versionchanged:: 3.1
       Added support for keyword arguments.

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to