Python staticmethod()

staticmethod() are a special case of methods. Any functionality that belongs to a class, but doesn’t require the object is placed in the static method. Static methods are similar to class methods. The main difference is that a static method doesn’t receive any additional arguments.

Remember that, a static method doesn’t use the self variable and it is defined using a built-in function named staticmethod. Python has a handy syntax, called a decoder is used to make it easier to apply the staticmethod function to the method function definition. It has the following syntax:

def name(args...):


class choice:
    def __init__(self, subjects):
        def validate_subject(subjects):
            if "C#" in subjects:
                print("This book is not available now!")
                return True
subjects=["C", "C++", "C#", "Java", "Python"]
if all(choice.validate_subject(i) for i in subjects ):
    print("You have already kept this book!")