From f7f8697b20a1d5cc839e5ba3d8bd24f058651731 Mon Sep 17 00:00:00 2001 From: Mark Pilgrim Date: Fri, 11 Sep 2009 15:36:08 -0400 Subject: [PATCH] clarified exactly what gets initialized in __init__ --- iterators.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iterators.html b/iterators.html index 38dc87e..0c8227d 100755 --- a/iterators.html +++ b/iterators.html @@ -258,7 +258,7 @@ rules = LazyRules() self.cache = []
  1. When we instantiate the LazyRules class, open the pattern file but don’t read anything from it. (That comes later.) -
  2. After opening the patterns file, initialize the cache and the cache index position. You’ll use these later (in the __next__() method) as you read lines from the pattern file. +
  3. After opening the patterns file, initialize the cache. You’ll use this cache later (in the __next__() method) as you read lines from the pattern file.

Before we continue, let’s take a closer look at rules_filename. It’s not defined within the __iter__() method. In fact, it’s not defined within any method. It’s defined at the class level. It’s a class variable, and although you can access it just like an instance variable (self.rules_filename), it is shared across all instances of the LazyRules class.