A Python identifier is a name used to identify a variable, function, class, module or other object. An identifier starts with a letter A to Z or a to z or an underscore (_) followed by zero or more letters, underscores and digits (0 to 9). An identifier cannot start with a digit. Python does not allow punctuation characters such as @, $, and % within identifiers.
Here are naming conventions for Python identifiers −
Class names start with an uppercase letter.
All other identifiers start with a lowercase letter.
Starting an identifier with a single leading underscore indicates that the identifier is private.
Starting an identifier with two leading underscores indicates a strongly private identifier.
If the identifier also ends with two trailing underscores, the identifier is a language-defined special name.
Rules for writing Identifiers in Python
The identifier is a combination of character digits and underscore and the character includes letters in lowercase (a-z), letters in uppercase (A-Z), digits (0-9), and an underscore (_).
An identifier cannot begin with a digit. If an identifier starts with a digit, it will give a Syntax error.
In Python, keywords are the reserved names that are built-in to Python, so a keyword cannot be used as an identifier - they have a special meaning and we cannot use them as identifier names.
Special symbols like !, @, #, $, %, etc. are not allowed in identifiers.
Python identifiers cannot only contain digits.
There is no restriction on the length of identifiers.