Skip to content

cls (argument)

In Python, cls is a conventional name for the first argument of a class method.

When you define a class method using the @classmethod decorator, the method’s first argument—which is required—will hold a reference to the class itself. Conventionally, this argument is called cls and allows you to use the class object inside the method.

Following this naming convention will make your code Pythonic and familiar to other Python developers.

Example

Here’s an example illustrating the use of cls in a class method:

Language: Python Filename: demo.py
class DemoClass:
    class_variable = "Hello, Class!"

    @classmethod
    def show_class_variable(cls):
        print(cls.class_variable)

# Usage
DemoClass.show_class_variable()  # Output: Hello, Class!

In this example, .show_class_variable() is a class method, and cls is used to access .class_variable from the class itself.

Python classmethods, staticmethods, and instance methods

Tutorial

Python's Instance, Class, and Static Methods Demystified

Compare instance methods vs class methods vs static methods in Python, and learn when each one earns its place in your code.

intermediate python

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

Have a question about this? Mentor AI can show you examples, compare related terms, and point you to tutorials.


By Leodanis Pozo Ramos • Updated July 9, 2026 • Reviewed by Dan Bader