squizyCake BorgSum 6274
Dimitry BorgSum 6029
f1import weakreff1import weakref
22
3class Borg:3class Borg:
n4    _instances = []n4    _all = []
55
6    def __init__(self, value=0):6    def __init__(self, value=0):
n7        self.value = valuen7        self._value = value
8        Borg._instances.append(weakref.ref(self))8        Borg._all.append(weakref.ref(self))
99
10    def __str__(self):10    def __str__(self):
n11        return str(self.value)n11        return str(self._value)
1212
13    def __iter__(self):13    def __iter__(self):
n14        for ref in Borg._instances:n14        for ref in Borg._all:
15            instance = ref()15            inst = ref()
16            if instance is not None:16            if inst is not None:
17                yield instance.value17                yield inst._value
1818
n19    def __iadd__(self, other):n19    def __iadd__(self, num):
20        for ref in Borg._instances:20        for ref in Borg._all:
21            instance = ref()21            inst = ref()
22            if instance is not None:22            if inst is not None:
23                instance.value += other23                inst._value += num
24        return self24        return self
2525
t26    def __isub__(self, other):t26    def __isub__(self, num):
27        for ref in Borg._instances:27        for ref in Borg._all:
28            instance = ref()28            inst = ref()
29            if instance is not None:29            if inst is not None:
30                instance.value -= other30                inst._value -= num
31        return self31        return self
Legends
Colors
 Added 
Changed
Deleted
Links
(f)irst change
(n)ext change
(t)op