Static method in the python:-
class Person:
no_of_paid_days = 10
def __init__(self,bname,agae,beducation):
self.name = bname
self.age = agae
self.education = beducation
def test(self):
print(f"The person name is {self.name} and the age of the person is {self.age} and the persona educatin is {self.education}")
# decoraters in the python .... ye by default class leta hai
@classmethod
# agar apko saab object me agar same ye wala variable call karna hai ya use karna hai to aap ye wale function ka use kar sakte hai
# is class ke saab instance ke liye wo kaam karenga
def change_paid_days(cls):
cls.no_of_paid_days = 55
# agar apko khali method banana hai to aap static method ka use kar sakte hai ... jisme apko utne hi resource aap use kar sako utne apko chaiye ... @staticmethod before function it's staic function
@staticmethod
def print_hello(string):
print("This is the static function " + string)
vishal = Person("vishal",458,"BSc it")
lakhan = Person("lakhan",458,5000)
# calling static method in the python
lakhan.print_hello("lakhan")
vishal.no_of_paid_days = Person.change_paid_days()
# print(lakhan.no_of_paid_days)
Thanks you for commenting your questions. I will see question and respond you.