add encoding parameter to all file open() calls in code samples, example files, and text

This commit is contained in:
Mark Pilgrim
2009-07-16 12:36:37 -04:00
parent 49fae282ec
commit e35d9d1bda
8 changed files with 24 additions and 23 deletions
+2 -2
View File
@@ -296,7 +296,7 @@ rules = []
<p class=d>[<a href=examples/plural5.py>download <code>plural5.py</code></a>]
<pre class=nd><code class=pp>def rules():
with open('plural5-rules.txt') as pattern_file:
with open('plural5-rules.txt', encoding='utf-8') as pattern_file:
for line in pattern_file:
pattern, search, replace = line.split(None, 3)
yield build_match_and_apply_functions(pattern, search, replace)
@@ -376,7 +376,7 @@ def plural(noun):
<p>Let&#8217;s go back to <code>plural5.py</code> and see how this version of the <code>plural()</code> function works.
<pre><code class=pp>def rules(rules_filename):
with open(rules_filename) as pattern_file:
with open(rules_filename, encoding='utf-8') as pattern_file:
for line in pattern_file:
<a> pattern, search, replace = line.split(None, 3) <span class=u>&#x2460;</span></a>
<a> yield build_match_and_apply_functions(pattern, search, replace) <span class=u>&#x2461;</span></a>