From: Raymond Hettinger Date: Sat, 23 Mar 2013 15:21:12 +0000 (-0700) Subject: Issue 17447: Clarify that str.isidentifier doesn't check for reserved keywords. X-Git-Tag: v3.4.0a1~1104^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=378170d5d95256ec17e20a5ce7dc1b6c99213874;p=thirdparty%2FPython%2Fcpython.git Issue 17447: Clarify that str.isidentifier doesn't check for reserved keywords. --- diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index 7e5f04f6c26f..60df11d130c9 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -1627,6 +1627,8 @@ 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`. .. method:: str.islower() diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 9f269a5bc2e9..c21e80c99d2e 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -11493,7 +11493,10 @@ PyDoc_STRVAR(isidentifier__doc__, "S.isidentifier() -> bool\n\ \n\ Return True if S is a valid identifier according\n\ -to the language definition."); +to the language definition.\n\ +\n\ +Use keyword.iskeyword() to test for reserved identifiers\n\ +such as \"def\" and \"class\".\n"); static PyObject* unicode_isidentifier(PyObject *self)