identifier

In Python, an identifier is a name that identifies a variable, function, class, module, or other object. Identifiers are fundamental for writing Python code because they allow you to refer to data and functions in your programs using descriptive names.

Identifiers must follow certain rules to be valid:

  • Consisting of letters (a-z, A-Z)
  • Including digits (0-9) but can’t start with a digit
  • Including underscores (_)
  • Being case-sensitive, meaning OneVariable, oneVariable, and ONEVARIABLE are distinct identifiers

You must know that most Python keywords can’t be used as identifiers. It’s important to choose meaningful and descriptive identifiers to make your code more readable and maintainable.

Examples

Here are a few quick examples of using identifiers in Python:

Python
# Constants
PI =3.142
MAX_SPEED = 300
DEFAULT_COLOR = "\033[1;34m"

# Variables
counter = 10
final_balance = 1_000.00
language = "Python"

# Function
def greet(name):
    return f"Hello, {name}!"

# Class
class Dog:
    def __init__(self, name):
        self.name = name

In these examples, you have several valid identifiers. You have constants, variables, a function, and a class. Each of them serves a different purpose within a Python program.

Tutorial

Variables in Python: Usage and Best Practices

In this tutorial, you'll learn how to use symbolic names called variables to refer to Python objects, and gain an understanding of how to effectively use these fundamental building blocks in your code to store, manipulate, and retrieve data.

basics python

For additional information on related topics, take a look at the following resources:


By Leodanis Pozo Ramos • Updated April 16, 2025