summaryrefslogtreecommitdiffstatshomepage
path: root/tests/basics/class_staticclassmethod.py
blob: 1cb59d5c7b65ec884f834203c775f206e15735ff (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# test static and class methods

class C:
    @staticmethod
    def f(rhs):
        print('f', rhs)
    @classmethod
    def g(self, rhs):
        print('g', rhs)

    # builtin wrapped in staticmethod
    @staticmethod
    def __sub__(rhs):
        print('sub', rhs)
    # builtin wrapped in classmethod
    @classmethod
    def __add__(self, rhs):
        print('add', rhs)

c = C()

c.f(0)
c.g(0)
c - 1
c + 2