DEV Community

datatoinfinity
datatoinfinity

Posted on • Edited on

Class Method and Self

Do check out Last Post
Well if you noticed correctly we are able to only fetch attribute not there full data or all attribute.
So how we can do that?

We have initialise the attribute but now we will work with them and perform operation on them or with them. so we will create function in which we perform operation which is a class method. Let say I want fetch every detail of Rohan.

class BankForm:
    def __init__(self,Name,DOB,AdhaarNo,PAN):
        self.Name=Name
        self.DOB=DOB
        self.AdhaarNo=AdhaarNo
        self.PAN=PAN
    def full_name(self):
        return f"{self.Name} {self.DOB} {self.AdhaarNo} {self.PAN}"
        
    
Rohan=BankForm("Rohan","12-09-2025","xxxx8907","KB1234")
print(Rohan.full_name())

will=BankForm("Will","12-09-2025","xxxx8907","KB1234")
print(will.full_name())

Please do remember that apply 'self' because it like telephone line which will connect to SBI

Top comments (0)