summaryrefslogtreecommitdiffstatshomepage
path: root/tests/basics/class_number.py
blob: e1dbf4a26c84e600e041cb8672a8bb232f72ba78 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# test class with __add__ and __sub__ methods

class C:
    def __init__(self, value):
        self.value = value

    def __add__(self, rhs):
        print(self.value, '+', rhs)

    def __sub__(self, rhs):
        print(self.value, '-', rhs)

c = C(0)
c + 1
c - 2