Return True if the string is a valid identifier according to the language definition, section Identifiers and keywords.
str.isidentifier()
>>> from keyword import iskeyword
>>> 'hello'.isidentifier(), iskeyword('hello')
(True, False)
>>> 'def'.isidentifier(), iskeyword('def')
(True, True)