forked from faif/python-patterns
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathborg.py
More file actions
Latest commit
24 lines (17 loc) · 497 Bytes
/
Copy pathborg.py
File metadata and controls
24 lines (17 loc) · 497 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
classBorg:
__shared_state= {}
def__init__(self):
self.__dict__=self.__shared_state
self.state='Running'
def__str__(self):
returnself.state
if__name__=='__main__':
rm1=Borg()
rm2=Borg()
print('rm1 state: {}'.format(rm1))
print('rm2 state: {}'.format(rm2))
rm2.state='Idle'
print('rm1 state: {}'.format(rm1))
print('rm2 state: {}'.format(rm2))
print('rm1 id: {}', id(rm1))
print('rm2 id: {}', id(rm2))