diff options
author | Sanyam Khurana <8039608+CuriousLearner@users.noreply.github.com> | 2018-10-08 06:53:32 (GMT) |
---|---|---|
committer | Carol Willing <carolcode@willingconsulting.com> | 2018-10-08 06:53:32 (GMT) |
commit | ffc5a14d00db984c8e72c7b67da8a493e17e2c14 (patch) | |
tree | 9baa64994bc84ab4351d4bbabbda67105a47ccbb /Doc/library | |
parent | 656d52dbfde3223cd2a3525d652b6cccb02fa991 (diff) | |
download | cpython-ffc5a14d00db984c8e72c7b67da8a493e17e2c14.zip cpython-ffc5a14d00db984c8e72c7b67da8a493e17e2c14.tar.gz cpython-ffc5a14d00db984c8e72c7b67da8a493e17e2c14.tar.bz2 |
bpo-33014: Clarify str.isidentifier docstring (GH-6088)
* bpo-33014: Clarify str.isidentifier docstring
* bpo-33014: Add code example in isidentifier documentation
Diffstat (limited to 'Doc/library')
-rw-r--r-- | Doc/library/stdtypes.rst | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index 5a133e3..d0d5c61 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -1700,8 +1700,19 @@ expression support in the :mod:`re` module). Return true if the string is a valid identifier according to the language definition, section :ref:`identifiers`. - Use :func:`keyword.iskeyword` to test for reserved identifiers such as - :keyword:`def` and :keyword:`class`. + Call :func:`keyword.iskeyword` to test whether string ``s`` is a reserved + identifier, such as :keyword:`def` and :keyword:`class`. + + Example: + :: + + >>> from keyword import iskeyword + + >>> 'hello'.isidentifier(), iskeyword('hello') + True, False + >>> 'def'.isidentifier(), iskeyword('def') + True, True + .. method:: str.islower() |