]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.14] gh-106318: Add example for str.isalnum() (GH-137550) (#144609)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Sun, 8 Feb 2026 22:14:19 +0000 (23:14 +0100)
committerGitHub <noreply@github.com>
Sun, 8 Feb 2026 22:14:19 +0000 (22:14 +0000)
gh-106318: Add example for str.isalnum() (GH-137550)
(cherry picked from commit 3dd7a3c65ad4ac330ad44a519efa017484530e1a)

Co-authored-by: Adorilson Bezerra <adorilson@gmail.com>
Doc/library/stdtypes.rst

index 23364b92ba39e9448a40f2f803bf69a1e234d519..07c73e16e6aa9eb43bdf635ceec33ad3f9c385f7 100644 (file)
@@ -2180,7 +2180,18 @@ expression support in the :mod:`re` module).
    Return ``True`` if all characters in the string are alphanumeric and there is at
    least one character, ``False`` otherwise.  A character ``c`` is alphanumeric if one
    of the following returns ``True``: ``c.isalpha()``, ``c.isdecimal()``,
-   ``c.isdigit()``, or ``c.isnumeric()``.
+   ``c.isdigit()``, or ``c.isnumeric()``. For example::
+
+   .. doctest::
+
+      >>> 'abc123'.isalnum()
+      True
+      >>> 'abc123!@#'.isalnum()
+      False
+      >>> ''.isalnum()
+      False
+      >>> ' '.isalnum()
+      False
 
 
 .. method:: str.isalpha()