summaryrefslogtreecommitdiffstatshomepage
path: root/tests/basics/class_new.py
blob: a6a34c58114d216a18796c4c54ef6852c823bd7a (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
26
27
28
29
30
31
32
class A:
    def __new__(cls):
        print("A.__new__")
        return super(cls, A).__new__(cls)

    def __init__(self):
        pass

    def meth(self):
        print('A.meth')

#print(A.__new__)
#print(A.__init__)

a = A()
a.meth()

a = A.__new__(A)
a.meth()

#print(a.meth)
#print(a.__init__)
#print(a.__new__)

# __new__ should automatically be a staticmethod, so this should work
a = a.__new__(A)
a.meth()

class B:
    def __new__(self, v1, v2):
        None
B(1, 2)