Identifiers

Identifiers are short pieces of text that are used as:

  • variables names

  • function names

  • function argument keywords

  • class names

  • module names

Unlike string literals they are not enclosed in quotation marks.

Identifiers are like string literals pieces of text but can be easily distinguished from each other

The variable name to the left of the equal sign = is not enclosed in quotation marks.

To get a valid, working identifier a small set of rules has to be followed:

  • It must not be one of the keywords

  • It may contain

    • lowercase and uppercase letters a .. z and A .. Z

    • digits 0 .. 9 except as the first character

    • underscores _

Actually Python 3 allows some additional characters, so letters like ä, ö, ü, ß could also be used.

Valid identifiers (used as a variable names)

Invalid identifiers

Each of the variables in the statements above throw an error (and aborts running the program).
► Try to correct all of them, one statment after the other, and watch the error messages.