classmethod()

We can use the class and its properties inside that method rather than a particular instance

classmethod has a reference to a class object as the first parameter. ( staticmethod has no reference )

Example:

class animals():
    def __init__(self,name,height):
        self.name= name
        self.height=height
    @classmethod
    def legs(cls):
        print("has four legs") 
#animals.legs=classmethod(animals.legs)
animals.legs()
Output
has four legs
or create a class method like this
animals.legs=classmethod(animals.legs)
animals.legs()
Class methods are useful when you need to have methods that aren’t specific to any particular instance, but still involve the class in some way
class animals():
    home='Jungle'
    def __init__(self,name,height):
        self.name= name
        self.height=height
    @classmethod
    def legs(cls):
        print("has four legs: stays in ",cls.home) 
animals.legs()
Output
has four legs: stays in  Jungle
In staticmethod() we are not going to pass any instance of class to it.
staticmethod()

Using isinstance()

By using isinstance() we can check if the object is instance of the class or not.

All Built in Functions in Python locals() dir() ord()
Subhendu Mohapatra — author at plus2net
Subhendu Mohapatra

Author

🎥 Join me live on YouTube

Passionate about coding and teaching, I publish practical tutorials on PHP, Python, JavaScript, SQL, and web development. My goal is to make learning simple, engaging, and project‑oriented with real examples and source code.



Subscribe to our YouTube Channel here



plus2net.com







Python Video Tutorials
Python SQLite Video Tutorials
Python MySQL Video Tutorials
Python Tkinter Video Tutorials
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
©2000-2025   plus2net.com   All rights reserved worldwide Privacy Policy Disclaimer