3.3. Identifiers

Identifiers are the set of valid strings which are allowed as names in a computer language. From this all-encompassing list, we segregate out those which are keywords, names that form a construct of the language. Such identifiers are reserved words which may not be used for any other purpose, or else a syntax error (SyntaxError exception) will occur.

Python also has an additional set of identifiers known as built-ins, and although they are not reserved words, use of these special names is not recommended. (Also see Section 3.3.3.)

3.3.1. Valid Python Identifiers

The rules for Python identifier strings are not unlike most other high-level programming languages:

  • First character must be letter or underscore ( _ )

  • Any additional characters ...

Get Core Python Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.