Locked learning resources

Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Locked learning resources

This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Python Method Types Recap & Review

This is the last video of the course providing you a quick recap of what you have learned so far about the three different method types.

Want more? Keep improving your Python OOP skills with our Object-Oriented Programming (OOP) With Python Learning Path.

Avatar image for sumankalyanr

sumankalyanr on June 12, 2019

Super cool explanation on method types in python.. I thoroughly enjoyed it.

Avatar image for Dan Bader

Dan Bader RP Team on June 12, 2019

@sumankalyanr: Thanks, that’s great to hear!

Avatar image for victorariasvanegas

victorariasvanegas on June 22, 2019

Great explanation , I’m really enjoying this class.

Avatar image for DiscreteLoner

DiscreteLoner on June 27, 2019

Awesome! I really enjoy this video set.

Avatar image for Technocrats Warnakala

Technocrats Warnakala on Aug. 9, 2019

super cool, it would be awesome if we get references to real world implementation as well, probably link to github/gitlab projects which has the usage of OOP Method

Avatar image for LJIN Lab

LJIN Lab on Aug. 10, 2019

Great tutorial, but real world examples would be great!

Avatar image for ThangHoang

ThangHoang on Aug. 21, 2019

Awesome, Thank you so much

Avatar image for blaqhrse

blaqhrse on Sept. 22, 2019

Thanks Dan; clear explanation but would like to echo the same as previous posts. Real world examples would really help drive it home.

Avatar image for mikesult

mikesult on March 3, 2020

Thanks for another good tutorial and thanks for the links to stackoverflow. There’s a lot of different opinions to digest.

Avatar image for Zarata

Zarata on April 20, 2020

I like the short, digestable (no Pizza pun intended, but I’ll take it), and on point. Thanks! IF I’m right and the “magic” is in the decorators to make things work one way or other, you might want to make special note of that. I’ve only seen decorator use here and there in the trails I’ve been following and I’ve already forgotten the bits I’ve seen.

Avatar image for Zarata

Zarata on April 20, 2020

Sorry … digestible.

Im sorry man, but I didnt find good information from this tutorial. Perhaps more and different use cases. I would have preferred a longer tutorial if it meant more and clear guidance on this topic.

Avatar image for Erikton Konomi

Erikton Konomi on May 20, 2020

Thanks Dan, but have to agree with others. The links from stackoverflow have some good information, but a couple solid examples in the tutorial itself would have been preferable.

I found this example helpful: stackabuse.com/pythons-classmethod-and-staticmethod-explained/

Avatar image for sroux53

sroux53 on June 8, 2020

Excellent !

Avatar image for Ghani

Ghani on Oct. 7, 2020

Good but “too compact”!

Avatar image for Mark Walle

Mark Walle on Dec. 2, 2020

Here is a bit of a deeper dive on this subject matter that still involves pizza (found via one of Dan’s stackoverflow posts linked above):


Avatar image for boardtc

boardtc on Jan. 27, 2021

@Mark Walle, thanks for link, that article explains about bounded & unbounded methods which gave me further understanding into the python way. One thing I wonder is does a method have to be either a class/cls method, a bound/self method, a static method or an abstract method…there are no other options for it to be just a method?

Avatar image for ephremworkeye

ephremworkeye on Aug. 16, 2021

Thank you so much!!! I have one question though: when we call @classmethod like Pizza.margherita(), does it mean we have created instance of class or object?


Avatar image for Martin Breuss

Martin Breuss RP Team on Aug. 16, 2021

Hi @ephremworkeye. Is it correct that you’re thinking of a @classmethod called margherita() that’s part of the Pizza class:

class Pizza:

    def margherita(cls):
        return "It's a pi'zza!"

This toy implementation doesn’t make much sense as a @classmethod, considering that the cls argument isn’t used in the body of the method. But since that’s not the point of your question, we can let it slide :)

So if you’re calling a @classmethod called margherita() that’s part of the Pizza class, then you can get the following output:

>>> Pizza.margherita()
"It's a pi'zza!"

>>> Pizza.margherita() == Pizza().margherita()

>>> Pizza.margherita
<bound method Pizza.margherita of <class '__main__.Pizza'>>

Where do you think the @classmethod belongs to when you look at this output, and what’s your interpretation of the results? Can you come up with another test that might help answer your question?

Avatar image for Tony Florido

Tony Florido on Dec. 26, 2021

@ephremworkeye instance of the class.

Become a Member to join the conversation.