From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Fri, 13 Jun 2025 11:46:06 +0000 (+0200) Subject: [3.14] gh-106318: Add example for `str.encode()` (GH-134520) (#135457) X-Git-Tag: v3.14.0b3~39 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f22aae190800728d8c71792da17268f0f2d80ba9;p=thirdparty%2FPython%2Fcpython.git [3.14] gh-106318: Add example for `str.encode()` (GH-134520) (#135457) 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 b75e5ceecf87..4854a2c077bb 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 ` 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.