Skip to content

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:

  • Consist of letters (a-z, A-Z)
  • Include digits (0-9) but can’t start with a digit
  • Include underscores (_)
  • Be case-sensitive, meaning OneVariable, oneVariable, and ONEVARIABLE are all different identifiers

You should 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. There are 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

Explore Python variables from creation to best practices, covering naming conventions, dynamic typing, variable scope, and type hints with examples.

basics python

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


By Leodanis Pozo Ramos • Updated March 10, 2026 • Reviewed by Dan Bader