Python @staticmethod Last Updated : 21 Nov, 2019 Comments Improve Suggest changes Like Article Like Report There can be some functionality that relates to the class, but does not require any instance(s) to do some work, static methods can be used in such cases. A static method is a method which is bound to the class and not the object of the class. It can’t access or modify class state. It is present in a class because it makes sense for the method to be present in class. A static method does not receive an implicit first argument. Syntax: class C(object): @staticmethod def fun(arg1, arg2, ...): ... Returns: a static method for function fun. When function decorated with @staticmethod is called, we don’t pass an instance of the class to it as it is normally done with methods. It means that the function is put inside the class but it cannot access the instance of that class. Example #1: Python3 1== # Python program to # demonstrate static methods class Maths(): @staticmethod def addNum(num1, num2): return num1 + num2 # Driver's code if __name__ == "__main__": # Calling method of class # without creating instance res = Maths.addNum(1, 2) print("The result is", res) Output: The result is 3 Example #2: Python3 1== # Python program to # demonstrate static methods class Person: def __init__(self, name, age): self.name = name self.age = age # a static method to check if a Person is adult or not. @staticmethod def isAdult(age): return age > 18 # Driver's code if __name__ == "__main__": res = Person.isAdult(12) print('Is person adult:', res) res = Person.isAdult(22) print('\nIs person adult:', res) Output: Is person adult: False Is person adult: True Comment More infoAdvertise with us Next Article Python @staticmethod N nikhilaggarwal3 Follow Improve Article Tags : Python Python-OOP Practice Tags : python Similar Reads Python staticmethod() Function Python staticmethod() function is used to convert a function to a static function. Static methods are independent of class instances, meaning they can be called on the class itself without requiring an object of the class.Example:Pythonclass Utility: def msg(name): return f"Hello, {name}!" msg = sta 6 min read Python Pyramid - Static Assets A lightweight web framework in Python that converts small web apps to large web apps is called Pyramid. There are various circumstances when the user needs to add some images, HTML code, CSS code, etc. along with the Python code in the web app. These are called static assets and can be added using t 5 min read Instance method in Python A class is a user-defined blueprint or prototype from which objects are created. Classes provide a means of bundling data and functionality together. Creating a new class creates a new type of object, allowing new instances of that type to be made. Each class instance can have attributes attached to 2 min read Class or Static Variables in Python All objects share class or static variables. An instance or non-static variables are different for different objects (every object has a copy). For example, let a Computer Science Student be represented by a class CSStudent. The class may have a static variable whose value is "cse" for all objects. 9 min read Bound, unbound, and static methods in Python Methods in Python are like functions except that it is attached to an object.The methods are called on objects and it possibly make changes to that object. These methods can be Bound, Unbound or Static method. The static methods are one of the types of Unbound method. These types are explained in de 5 min read Multimethods in Python Multimethod basically means a function that has multiple versions, distinguished by the type of the arguments. For better understanding consider the below example. @multimethod def sum(x: int, y: int): return x + y @multimethod def sum(x: str, y: str): return x+" "+y The above example is similar to 2 min read Python Version History Python, one of the most popular programming languages today, has a rich history of development and evolution. From its inception in the late 1980s to its current status as a versatile and powerful language, Python's version history reflects the language's adaptability and the community's dedication 5 min read Python __add__() magic method Python __add__() function is one of the magic methods in Python that returns a new object(third) i.e. the addition of the other two objects. It implements the addition operator "+" in Python. Python __add__() Syntax Syntax: obj1.__add__(self, obj2) obj1: First object to add in the second object.obj2 1 min read What Is the @ Symbol in Python? Understanding the significance of the "@" symbol in Python is crucial for writing code that's both tidy and efficient, especially when you're dealing with decorators or performing matrix multiplication operations in your programs. In this article, we'll delve into the role of the "@" symbol in Pytho 3 min read wxPython - Create() function in wx.StaticText In this article we are going to learn about Create() associated with wx.StaticText class of wxPython. A static text control displays one or more lines of read-only text. Create() function is used for two step creation of static text. It takes attributes of statictext as arguments. Syntax: wx.StaticT 1 min read Like