Skip to main content

classmethod() in Python

In Python, classmethod() is an built-in function. The classmethod() method returns a class method for the given function.

A class method is a method that is bound to a class rather than its object. It doesn't require creation of a class instance. 

It can be called as a both class or object.




This function accepts the function name as a parameter that needs to be converted into a class method.

Return Values:

This function returns the converted class method.


class abc():
    place = "xyz"
    def place_1(obj):
        print("The place is:",
abc.place_1 = classmethod(abc.place_1)

Output: The place is: xyz

Submitted by devanshi.srivastava on July 8, 2021

Devanshi, is working as a Data Scientist with iVagus. She has expertise in Python, NumPy, Pandas and other data science technologies.


At ProgramsBuzz, you can learn, share and grow with millions of techie around the world from different domain like Data Science, Software Development, QA and Digital Marketing. You can ask doubt and get the answer for your queries from our experts.