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 info N nikhilaggarwal3 Follow Improve Article Tags : Python Python-OOP Explore Python FundamentalsPython Introduction 3 min read Input and Output in Python 4 min read Python Variables 5 min read Python Operators 5 min read Python Keywords 2 min read Python Data Types 8 min read Conditional Statements in Python 3 min read Loops in Python - For, While and Nested Loops 7 min read Python Functions 5 min read Recursion in Python 6 min read Python Lambda Functions 5 min read Python Data StructuresPython String 5 min read Python Lists 5 min read Python Tuples 4 min read Python Dictionary 3 min read Python Sets 6 min read Python Arrays 7 min read List Comprehension in Python 4 min read Advanced PythonPython OOP Concepts 11 min read Python Exception Handling 5 min read File Handling in Python 4 min read Python Database Tutorial 4 min read Python MongoDB Tutorial 2 min read Python MySQL 9 min read Python Packages 12 min read Python Modules 7 min read Python DSA Libraries 15 min read List of Python GUI Library and Packages 3 min read Data Science with PythonNumPy Tutorial - Python Library 3 min read Pandas Tutorial 6 min read Matplotlib Tutorial 5 min read Python Seaborn Tutorial 15+ min read StatsModel Library- Tutorial 4 min read Learning Model Building in Scikit-learn 8 min read TensorFlow Tutorial 2 min read PyTorch Tutorial 7 min read Web Development with PythonFlask Tutorial 8 min read Django Tutorial | Learn Django Framework 7 min read Django ORM - Inserting, Updating & Deleting Data 4 min read Templating With Jinja2 in Flask 6 min read Django Templates 7 min read Python | Build a REST API using Flask 3 min read How to Create a basic API using Django Rest Framework ? 4 min read Python PracticePython Quiz 3 min read Python Coding Practice 1 min read Python Interview Questions and Answers 15+ min read Like