Skip to content

Commit b20923e

Browse files
author
Sakis Kasampalis
committed
fixed a borg bug
1 parent 7b5d9fb commit b20923e

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

borg.py

+20-8
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,34 @@ class Borg:
33

44
def __init__(self):
55
self.__dict__ = self.__shared_state
6-
self.state = 'Running'
76

87
def __str__(self):
98
return self.state
109

10+
class YourBorg(Borg):
11+
pass
12+
1113
if __name__ == '__main__':
1214
rm1 = Borg()
1315
rm2 = Borg()
1416

15-
print('rm1 state: {}'.format(rm1))
16-
print('rm2 state: {}'.format(rm2))
17+
rm1.state = 'Idle'
18+
rm2.state = 'Running'
19+
20+
print('rm1:', rm1)
21+
print('rm2:', rm2)
22+
23+
rm2.state = 'Zombie'
24+
25+
print('rm1:', rm1)
26+
print('rm2:', rm2)
27+
28+
print('rm1 id:', id(rm1))
29+
print('rm2 id:', id(rm2))
1730

18-
rm2.state = 'Idle'
31+
rm3 = YourBorg()
1932

20-
print('rm1 state: {}'.format(rm1))
21-
print('rm2 state: {}'.format(rm2))
33+
print('rm1:', rm1)
34+
print('rm2:', rm2)
35+
print('rm3:', rm3)
2236

23-
print('rm1 id: {}', id(rm1))
24-
print('rm2 id: {}', id(rm2))

0 commit comments

Comments
 (0)