Python @staticmethod vs @classmethod - What's the difference?

preview_player
Показать описание
In this video, I explain the difference between the Python staticmethod and classmethod class decorators. Additionally, you will learn why Python functions are first-class objects and how to use decorators in Python.

Recording Gear

⏰ Timestamps:
0:00 Intro
0:30 Python functions are first-class objects
0:47 Python higher-order functions
2:05 Python functions inside functions
3:46 Introduction to Python decorators
4:52 Python @staticmethod
7:32 Python @classmethod
9:53 Summary
Рекомендации по теме
Комментарии
Автор

This is the best description that I can find on YouTube about this topic. Thank you and keep going.

twoglassesofwhiskey.
Автор

Meehn, you have no Idea how helpful this tutorial was. I was starting to get frustrated but now I understand the difference between the two classes. Thanks

njorogekamau
Автор

Thank you. This is the best video I've seen on static and class methods. Liked and subscribed.

steveowen
Автор

Excellent work brothe.Your explanation is really amazing and it helps a lot to understand vague concepts easily!

RameezRaja-qcfi
Автор

Best explanation about these two methods.Kudos!

sarojpaudel
Автор

Excellent explanation sir. I was having a hard time understanding what they are and how they work. Thank you!

grassifuentes
Автор

grt tutorial..learnt decorators, types of decorators used in class

soniathomase
Автор

Great video, k0nze, very clear explanation :) 💻

isaacdiazrodriguez
Автор

Really good explanation with clear example
Thank you brother

rajumurugesan
Автор

Finally got to understand decorators topic. 👏🏿

LifeOf
Автор

Thx for the help bro, ur content is awesome !!!

guilhermevargas
Автор

💻Thank you. This is an amazingly good explanation.

ToddBradley-pzjr
Автор

u deserve more subs man, feels bad for you
your content quality is A+

e-nvy
Автор

Why give you a diffcult example with diffcult functions first. If someone is able to understand the function at 2:08 then you can assume they know how deocrators are working.

xsme
Автор

I have the following using Python 3.10:


class A:
count = 0

def __init__(self):
self.acc = 1

@classmethod
def func1(cls):
return cls.count

def func2(self):
return self.count


if __name__ == "__main__":
a = A()
print(a.count)
print(a.func1())
print(a.func2())


Output:

0
0
0

robsonjunior
Автор

Awesome explanation Looks like u read O'Reily books they are exhaustive but has some real stuff.

Keep up the good word.
God bless you & ur family

zameerahmed
Автор

Couldn't disagree with the comments in this video more. Felt like you just read out code that works very quickly and didn't do much to explain what was actually happening.

imnottellingyoumyname
join shbcf.ru