Identifiers are the names given to different entities such as variable name, class name, function name, etc.
Rules for naming Python identifiers
- An identifier can contain small letters (a – z), capital letters (A – Z), an underscore (_), and digits (0 to 9).
- An identifier must begin with letter, underscore but not with a digit.
- Python does not allow punctuation, special characters such as @, $, and % within identifiers.
- Python is a case sensitive programming language. Thus, FirstNumber and firstnumber are two different identifiers in Python.
- Class names start with an uppercase 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.
- A keyword cannot be used as an identifier.