1
2
3
4 __author__ = "Karsten.Hilbert@gmx.net"
5 __license__ = "GPL v2 or later"
6
7
9 """A generic Borg mixin for new-style classes.
10
11 - mixin this class with your class' ancestors to borg it
12
13 - there may be many _instances_ of this - PER CHILD CLASS - but they all share _state_
14 """
15 _instances = {}
16
23
24
25 if __name__ == '__main__':
26
27 import sys
28
29 if len(sys.argv) < 2:
30 sys.exit()
31
32 if sys.argv[1] != 'test':
33 sys.exit()
34
35
38
41
45
46 print("testing new-style classes borg")
47 a1 = A()
48 a2 = A()
49 a1.a = 5
50 print(a1.a, "==", a2.a)
51 a3 = A()
52 print(a1.a, "==", a2.a, "==", a3.a)
53 b1 = B()
54 b1.a = 10
55 print(b1.a)
56 print(a1.a)
57 b2 = B()
58 print(b2.a)
59
60 c1 = C(val = 'non-default')
61 print(c1.x)
62 c2 = C(val = 'non-default 2')
63 print(c2.x)
64 c3 = C()
65 print(c3.x)
66
67
68