What is a static method in Python?
Experience Level: Junior
Tags: Python
Answer
Static method is a method that is decorated by @staticmethod decorator.
It is a method that doesn't know anything about state of the class it is defined in. It's not able to read class values. It only accepts values passed by parameters and optionally return a value.
Related Python job interview questions
How do you reraise an exception in Python?
Python JuniorWhy should you use private and protected methods instead of defining all methods as public in Python?
Python JuniorWhy should you convert your private class methods to static methods in Python whenever possible?
Python JuniorHow do you comment out code in Python using multi-line comment?
Python JuniorHow do you comment out code in Python using single-line comment?
Python Junior