Class method in python

technical talkiess
0

 Method class :- 

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




vishal = Person("vishal",458,"BSc it")

lakhan = Person("lakhan",458,5000)


# vishal.no_of_paid_days = Person.change_paid_days()

print(lakhan.no_of_paid_days)

Post a Comment

0Comments

Thanks you for commenting your questions. I will see question and respond you.

Post a Comment (0)