File tree 1 file changed +20
-8
lines changed
1 file changed +20
-8
lines changed Original file line number Diff line number Diff line change @@ -3,22 +3,34 @@ class Borg:
3
3
4
4
def __init__ (self ):
5
5
self .__dict__ = self .__shared_state
6
- self .state = 'Running'
7
6
8
7
def __str__ (self ):
9
8
return self .state
10
9
10
+ class YourBorg (Borg ):
11
+ pass
12
+
11
13
if __name__ == '__main__' :
12
14
rm1 = Borg ()
13
15
rm2 = Borg ()
14
16
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 ))
17
30
18
- rm2 . state = 'Idle'
31
+ rm3 = YourBorg ()
19
32
20
- print ('rm1 state: {}' .format (rm1 ))
21
- print ('rm2 state: {}' .format (rm2 ))
33
+ print ('rm1:' , rm1 )
34
+ print ('rm2:' , rm2 )
35
+ print ('rm3:' , rm3 )
22
36
23
- print ('rm1 id: {}' , id (rm1 ))
24
- print ('rm2 id: {}' , id (rm2 ))
You can’t perform that action at this time.
0 commit comments