diff options
| author | Georg Brandl <georg@python.org> | 2011-07-04 19:58:12 +0200 |
|---|---|---|
| committer | Georg Brandl <georg@python.org> | 2011-07-04 19:58:12 +0200 |
| commit | 5cb4efc23896173e283b5ed627a68da2eb57130d (patch) | |
| tree | 90216a70bc8cee3c5ed114c376414ea417bfac3f /Doc/tutorial/stdlib2.rst | |
| parent | 2515f007a9b6a4a65e3ef8514f5d425c2d17a8ec (diff) | |
| parent | 268982261f726df46804b1a23dc09ecece24cdc1 (diff) | |
| download | cpython-5cb4efc23896173e283b5ed627a68da2eb57130d.tar.gz | |
Merge with 3.2.
Diffstat (limited to 'Doc/tutorial/stdlib2.rst')
| -rw-r--r-- | Doc/tutorial/stdlib2.rst | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/Doc/tutorial/stdlib2.rst b/Doc/tutorial/stdlib2.rst index fe7f027b53..85c88dc23f 100644 --- a/Doc/tutorial/stdlib2.rst +++ b/Doc/tutorial/stdlib2.rst @@ -141,7 +141,9 @@ standard size and in little-endian byte order:: import struct - data = open('myfile.zip', 'rb').read() + with open('myfile.zip', 'rb') as f: + data = f.read() + start = 0 for i in range(3): # show the first 3 file headers start += 14 @@ -271,7 +273,7 @@ applications include caching objects that are expensive to create:: Traceback (most recent call last): File "<stdin>", line 1, in <module> d['primary'] # entry was automatically removed - File "C:/python31/lib/weakref.py", line 46, in __getitem__ + File "C:/python33/lib/weakref.py", line 46, in __getitem__ o = self.data[key]() KeyError: 'primary' |
