what is a class method in python

0 votes
what is a class method in python.

how is it different from a static method in python?
Mar 12, 2019 in Python by Waseem
• 4,540 points
1,212 views

2 answers to this question.

0 votes

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

DIFFERENCE BETWEEN CLASS METHOD AND STATICS METHOD 

  • Static method knows nothing about the class and just deals with the parameters
  • Class method works with the class since its parameter is always the class itself.

class method can be called by  the class and its object.

Class.classmethod()

        OR

Class().classmethod()

these both method are very frequently  used in python and it is one of the essential concept of python.it is very necessary to understand the concept of class method and statics method for having good experience and skill with regards to python.

answered Mar 19, 2019 by rajesh kumar
0 votes

Class Method 

  1. class method is the method which is bound to the class and not the object of the class.
  2. They have the access to the state of the class as it takes a class parameter that points to the class and not the object instance.
  3. It can modify a class state that would apply across all the instances of the class. For example it can modify a class variable that will be applicable to all the instances.

Static Method

  1. A static method is also a method which is bound to the class and not the object of the class.
  2. A static method can’t access or modify class state.
  3. It is present in a class because it makes sense for the method to be present in class.

answered Apr 8, 2019 by MrBoot
• 1,230 points

Related Questions In Python

0 votes
1 answer

How does Python know whether a variable in the class is a method or a variable?

In python objects/variables are wrapped into methods ...READ MORE

answered Sep 18, 2018 in Python by aryya
• 7,460 points
1,163 views
0 votes
1 answer

What is a “method” in Python?

It's a function which is a member ...READ MORE

answered Oct 23, 2018 in Python by SDeb
• 13,300 points
749 views
+1 vote
7 answers
0 votes
1 answer

What is the meaning of “int(a[::-1])” in Python?

Assumming a is a string. The Slice ...READ MORE

answered Aug 27, 2018 in Python by Priyaj
• 58,020 points
6,471 views
0 votes
1 answer

What is the process to kill a particular thread in python?

A multiprocessing.Process can p.terminate() In the cases where I want to ...READ MORE

answered Feb 4, 2019 in Python by charlie_brown
• 7,720 points
3,715 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,434 views
0 votes
1 answer
+5 votes
6 answers

Lowercase in Python

You can simply the built-in function in ...READ MORE

answered Apr 11, 2018 in Python by hemant
• 5,790 points
4,070 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP