File tree Expand file tree Collapse file tree 1 file changed +20
-8
lines changed
Expand file tree Collapse file tree 1 file changed +20
-8
lines changed Original file line number Diff line number Diff 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+
1113if __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 ))
You can’t perform that action at this time.
0 commit comments