From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Fri, 13 Jun 2025 11:46:14 +0000 (+0200) Subject: [3.13] gh-106318: Add example for `str.encode()` (GH-134520) (#135458) X-Git-Tag: v3.13.6~217 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=db408a484c607ad6cfbced889467c8d8823093d5;p=thirdparty%2FPython%2Fcpython.git [3.13] gh-106318: Add example for `str.encode()` (GH-134520) (#135458) Co-authored-by: Blaise Pabon Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> --- diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index a3c542745979..a32dee4ca572 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -1705,6 +1705,14 @@ expression support in the :mod:`re` module). unless an encoding error actually occurs, :ref:`devmode` is enabled or a :ref:`debug build ` is used. + For example:: + + >>> encoded_str_to_bytes = 'Python'.encode() + >>> type(encoded_str_to_bytes) + + >>> encoded_str_to_bytes + b'Python' + .. versionchanged:: 3.1 Added support for keyword arguments.