Emploee object at 0x00000235CB4CED50

technical talkiess
0

 Agar aap kisi bhi function ko apko agar property jaise use karna hai to aap direct nahi kar sakte hai iske liye apko @property likhna hoga function ke upper 


Error :- 


<bound method Emploee.email of <__main__.Emploee object at 0x00000235CB4CED50>>

Error code :- 

class Emploee:

    def __init__(self,fname,lname):

        self.fname = fname

        self.lname = lname

        # ye property easly access hogi jaab object se call karnege

        # self.email = fname + lname +"@gmail.com"


        # ye function apko property jaise acccess karna hai to aap @property ka use kar sakte hai

        #

       def email(self):

        return f"{self.email}"

   



    # creating the object of the particular class


vishal = Emploee("Vishal","Usrate")

lakhan = Emploee("Vishal","Usrate")


print(vishal.email)


Solution:- 

class Emploee:

    def __init__(self,fname,lname):

        self.fname = fname

        self.lname = lname

        # ye property easly access hogi jaab object se call karnege

        # self.email = fname + lname +"@gmail.com"


        # ye function apko property jaise acccess karna hai to aap @property ka use kar sakte hai

        #

    @property

    def email(self):

        return f"{self.email}"

   



    # creating the object of the particular class


vishal = Emploee("Vishal","Usrate")

lakhan = Emploee("Vishal","Usrate")


print(vishal.email)


Use only @property before the function

Post a Comment

0Comments

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

Post a Comment (0)