]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-106318: Add example for str.isalnum() (#137550)
authorAdorilson Bezerra <adorilson@gmail.com>
Sun, 8 Feb 2026 22:08:18 +0000 (22:08 +0000)
committerGitHub <noreply@github.com>
Sun, 8 Feb 2026 22:08:18 +0000 (00:08 +0200)
Doc/library/stdtypes.rst

index 0f20163e69509cd969675f51ff86884859f8b7de..4fc6f3b96521655f96426ea916082481b9be196b 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()