Python classmethod() function

Published February 17, 2022

The classmethod() is a built-in Python function that returns a class method when it is called.
The Syntax of classmethod()
The classmethod() method has the following syntax:

classmethod(function)


A single parameter is passed to the classmethod() method:
function- functions that need to be converted into class methods


Example

class Student:
    course = "Computer Science"
    def printCourse(a):
        print('My Course is:', a.course)
Student.printCourse = classmethod(Student.printCourse)
Student.printCourse()


Output

My Course is: Computer Science

 

 

Download Source code

 

 

Tags: Google Docs, Google Docs Page, Docs page size

Related Google Docs examples

How to change background on google docs

How to rotate text in google docs

How do i add/remove Header and Footer in Google doc

How do i set Page size in Google doc

How do i add Image in Google doc and crop/resize image in Google doc

How do i duplicate page in Google docs

How do i convert Google doc to PDF

How do i add/remove page numbers on Google doc

How do i add watermark in Google Doc

How to make Google docs view only

Article Contributed By :
https://www.rrtutors.com/site_assets/profile/assets/img/avataaars.svg

240 Views