open file as late as possible (in __iter__, not __init__)

This commit is contained in:
Mark Pilgrim
2009-07-14 00:28:46 -04:00
parent d86eb45f24
commit 34bbe9e9d6
2 changed files with 8 additions and 11 deletions
Regular → Executable
+1 -3
View File
@@ -17,11 +17,9 @@ def build_match_and_apply_functions(pattern, search, replace):
class LazyRules:
rules_filename = 'plural6-rules.txt'
def __init__(self):
def __iter__(self):
self.pattern_file = open(self.rules_filename)
self.cache = []
def __iter__(self):
self.cache_index = 0
return self