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

Поделиться
HTML-код
  • Опубликовано: 19 июн 2024
  • 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.
    ⏬ Python Cheat Sheets: k0nze.gumroad.com
    👉 Website Article for this Video: k0nze.dev/posts/python-static...
    💌 Support me on Patreon: / k0nze
    ☕️ Buy me Coffee: www.buymeacoffee.com/k0nze
    🌍 Check out my Website: k0nze.dev
    💻 Join our Discord: discord.k0nze.dev
    👔 Follow me on LinkedIn: linkedin.k0nze.dev
    Recording Gear
    Camera - Sony A6400: geni.us/zRw1
    Lens - Viltrox AF 23mm f1.4: geni.us/RVrguGd
    Microphone - Rode Wireless Go: geni.us/RBAOIx
    Keyboard - Keychron K2 v2: geni.us/DPK87Xn
    ⏰ 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

Комментарии • 41

  • @k0nze_builds
    @k0nze_builds  2 года назад +3

    Get your FREE Python Cheat Sheets: k0nze.gumroad.com

  • @twoglassesofwhiskey.324
    @twoglassesofwhiskey.324 2 года назад +7

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

  • @rajumurugesan6927
    @rajumurugesan6927 14 дней назад

    Really good explanation with clear example
    Thank you brother

  • @RameezRaja-qc9fi
    @RameezRaja-qc9fi Год назад +3

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

  • @njorogekamau3820
    @njorogekamau3820 6 месяцев назад

    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

  • @isaacdiazrodriguez8176
    @isaacdiazrodriguez8176 Год назад

    Great video, k0nze, very clear explanation :) 💻

  • @sarojpaudel7479
    @sarojpaudel7479 Год назад

    Best explanation about these two methods.Kudos!

  • @OlgaAl_1
    @OlgaAl_1 Год назад

    That's brilliant! Thank you ❤

  • @LifeOf97
    @LifeOf97 Год назад

    Finally got to understand decorators topic. 👏🏿

  • @soniathomase7757
    @soniathomase7757 11 месяцев назад

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

  • @ToddBradley-pz2jr
    @ToddBradley-pz2jr 3 месяца назад

    💻Thank you. This is an amazingly good explanation.

  • @grassifuentes
    @grassifuentes 8 месяцев назад

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

  • @guilhermevargas6447
    @guilhermevargas6447 2 года назад +1

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

    • @k0nze_builds
      @k0nze_builds  2 года назад

      I'm happy you liked the video Guilherme!

  • @aryangautam7506
    @aryangautam7506 Год назад

    Fantastic explanation

  • @esphilee
    @esphilee Год назад

    Good explanation. 👍👍👍

  • @sahil5124
    @sahil5124 8 месяцев назад

    thank you so much

  • @mad7505
    @mad7505 Год назад

    When comeback?
    Great tuts!

  • @e-nvy
    @e-nvy 2 года назад +1

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

    • @k0nze_builds
      @k0nze_builds  2 года назад +1

      Thank you Tanveer! It takes time to build subscribers and I'm happy where I'm at.

  • @robsonjunior2483
    @robsonjunior2483 Год назад

    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

  • @brianwkinyua
    @brianwkinyua 5 дней назад

    🖥

  • @rakeshbidhar8812
    @rakeshbidhar8812 Год назад

    This is the best explanation. Period.

    • @k283
      @k283 Год назад

      No, it's not..

  • @pushpakpugazhavan5382
    @pushpakpugazhavan5382 6 месяцев назад

    💻

  • @brahimlotfi5403
    @brahimlotfi5403 Год назад

    📺

  • @gamaleldinhazem2568
    @gamaleldinhazem2568 Год назад

    🖥️

  • @zameerahmed1775
    @zameerahmed1775 Год назад

    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

  • @xs2me223
    @xs2me223 2 месяца назад

    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.

  • @imnottellingyoumyname3050
    @imnottellingyoumyname3050 2 месяца назад

    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.

  • @nivethanyogarajah1493
    @nivethanyogarajah1493 9 месяцев назад

    🖥

  • @juliopchile
    @juliopchile Год назад

    💻

  • @chikechiagbaizu5392
    @chikechiagbaizu5392 10 месяцев назад

    🖥

  • @shivar8023
    @shivar8023 Год назад

    🖥

  • @oogieboogie7028
    @oogieboogie7028 Год назад

    🖥

  • @RaftxoWysocki
    @RaftxoWysocki Год назад

    🖥