techhub/python/Python-Identifiers

Python Identifiers and Naming Rules – Complete Guide

Identifiers are one of the most fundamental concepts in Python programming. An identifier is simply the name used to represent variables, functions, classes, objects, or modules. Choosing the right names and following Python’s rules makes code cleaner, easier to understand, and avoids errors.

This guide covers identifiers, naming conventions, reserved words, statements, indentation, comments, blank lines, and multi-line statements in Python—all with examples.

Identifiers: A Quick Go-through

Definition

  • An identifier is the name given to a variable, function, class, module, or object.
  • Identifiers must follow specific rules set by Python.
  • They uniquely identify elements in your program.

Examples:

# Variables
my_name = "Alice"  

# Functions
def get_total():
    return 100  

# Classes
class Employee:
    pass  
  • Here, my_name is the identifier.
  • It identifies the variable that stores the string "Alice".
  • Whenever you use my_name, Python knows you are referring to this variable.

Explanation:
my_name is the name that uniquely identifies the variable in memory. If you later write print(my_name), Python looks up the identifier my_name and fetches "Alice".

Scroll to Top