Python Identifiers and Keywords

Here we’ll discuss Python Identifiers and Keywords.

Python Identifiers

A Python identifier is a name used to identify a class, variable, module, function, or any other object.  It helps to differentiate one entity from another. Python does not allow punctuation characters within identifiers. Python is a case-sensitive programming language. Thus, Python and python are two different identifiers.

Python Identifiers and Keywords

Rules for Python Identifiers:

  • Python identifier names are case sensitive.
  • An identifier starts with a letter A to Z or a to z.
  • You can’t use reserved keywords as an identifier name.
  • Identifier name can’t start with a digit.
  • Python identifier name can start with an underscore.
  • There is no limit on the length of the identifier name.
  • Can’t use the special character as an identifier in python.
  • Creating an identifier, starting with two leading underscores indicates a strongly private identifier.

Python Valid Identifiers Examples:

Here are some valid identifiers examples,

  • xyz890 = Identifier containing numbers and alphabets.
  • _ijk = Identifier can start with an underscore.
  • mno_45 = Identifier containing all the valid characters.

Python Invalid Identifiers Examples:

Here are some invalid identifiers examples,

  • 45467 = Identifier can’t be only digits.
  • not = It’s a reserved keyword.
  •  a-b = The only special character allowed is an underscore.
  • 89abd = Identifier can’t start with a number.

Python Keywords:

The python programming keywords are saved or reserved words. These words can’t be utilized as the work title, variable title, and any identifier title, etc. Each keyword incorporates a particular meaning. Essentially, python programming keywords are utilized to characterize the sentence structure and structure of the Python language.

Here are some keywords used in python,

FalseasyncelseasTrueand
assertelifdelglobalnotwith
awaitifimportdefclasscontinue
passorNonefromfinallyfor
breakyieldinnonlocalislambda
exceptandraisewhilereturntry