Clas methods and static methods | SoloLearn: Learn to code for FREE!

+1

Clas methods and static methods

Whts the difference between class and static method

6/11/2020 6:41:30 PM

Manisha

5 Answers

New Answer

+6

HonFu thank you for that very good, simple explanation. You nailed it, and I think I needed to see it written to help me remember the difference. Thank you! Thank you! 😎👍 Manisha thank you for asking the question. I have been struggling on some of the OOP concepts and this helped. 👍

+4

Classmethods AND static methods can be called without an instance. Try this: class C: @classmethod def f(cls): print('Method of', cls) C.f() The main difference is that static methods have no implicit first argument, neither self (the instance) nor cls (the class).

+2

Manisha The main difference is static method can be call without creating the object of class means we can directly access with class.

+1

Manisha while reviewing OOP again and still not fully grasping everthing I found another awesome series on youtube that really made things understandable: https://www.youtube.com/playlist?list=PL-osiE80TeTsqhIuOqKhwlXsIBIdSeYtc There is a video dedicated to class and static methods: https://youtu.be/rq8cL2XMM5M (And thank you SoloLearn for getting me started, but your OOP curriculum could use some rework... a lot of users agree, read the comments. 😉).