Evet, örnek metotlarının içine argüman olarak örnekleri gönderiyoruz. Daha basit olan aşağıdaki örneğe bakın isterseniz.
class Test:
def __init__(self, x: int):
self.x = x
def topla(self, other: "Test"):
return self.x + other.x
ornek1 = Test(x=10)
ornek2 = Test(x=20)
print(ornek1.topla(other=ornek2))
Not: Burada other
parametresine isterseniz örneğin kendisini de verebilirsiniz.
print(ornek1.topla(other=ornek1))