浏览代码

added the state variable to borg and improved the README

Sakis Kasampalis 11 年之前
父节点
当前提交
ba8afd7a72
共有 3 个文件被更改,包括 9 次插入7 次删除
  1. 3 2
      README.md
  2. 0 0
      append_output.sh
  3. 6 5
      borg.py

+ 3 - 2
README.md

@@ -1,10 +1,11 @@
 python-patterns
 python-patterns
 ===============
 ===============
 
 
-A collection of design patterns implemented (by other people) in python.
+A collection of design patterns and idioms in Python.
 
 
 When an implementation is added or modified, be sure to update this file and
 When an implementation is added or modified, be sure to update this file and
-rerun `append_output.sh` to keep the output comments at the bottom up to date.
+rerun `append_output.sh` (eg. ./append_output.sh borg.py) to keep the output
+comments at the bottom up to date.
 
 
 Current Patterns:
 Current Patterns:
 
 

+ 0 - 0
append_output.sh


+ 6 - 5
borg.py

@@ -7,6 +7,7 @@ class Borg:
 
 
     def __init__(self):
     def __init__(self):
         self.__dict__ = self.__shared_state
         self.__dict__ = self.__shared_state
+        self.state = 'Init'
 
 
     def __str__(self):
     def __str__(self):
         return self.state
         return self.state
@@ -44,8 +45,8 @@ if __name__ == '__main__':
 # rm2: Running
 # rm2: Running
 # rm1: Zombie
 # rm1: Zombie
 # rm2: Zombie
 # rm2: Zombie
-# rm1 id: 139825262601040
-# rm2 id: 139825262601104
-# rm1: Zombie
-# rm2: Zombie
-# rm3: Zombie
+# rm1 id: 140732837899224
+# rm2 id: 140732837899296
+# rm1: Init
+# rm2: Init
+# rm3: Init