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 11 in Python by Waseem
• 2,670 points
27 views

2 answers to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
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 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.

If you want to know more about Python then i suggest you to pursue Diploma in Python Courses or Python Certification from where you can gain lots of knowledge and information.

answered Apr 8 by MrBoot
• 1,210 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 ariaholic
• 7,320 points
29 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
• 10,780 points
15 views
+1 vote
3 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
• 56,140 points
55 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 in Python by charlie_brown
• 7,710 points
34 views
0 votes
1 answer

how can i count the items in a list?

suppose you have a list a = [0,1,2,3,4,5,6,7,8,9,10] now ...READ MORE

answered May 2 in Python by Mohammad
• 1,400 points
55 views
+4 votes
6 answers

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.