PyDocs

Nav

Python Runtime Services

str.isidentifier

builtins

method of str
  • str.isidentifier()
Return True if the string is a valid Python identifier, False otherwise.

Call keyword.iskeyword(s) to test whether string s is a reserved
identifier, such as "def" or "class".
1 Example
>>> from keyword import iskeyword

>>> 'hello'.isidentifier(), iskeyword('hello')
(True, False)
>>> 'def'.isidentifier(), iskeyword('def')
(True, True)
from the Python docs
See Also
No see-alsos for builtins/str.isidentifier
0 Notes
No notes for str.isidentifier