mirror of
https://github.com/kennethreitz/dive-into-python3.git
synced 2026-06-05 23:10:17 +00:00
quoting attribute values is a hard habit to break
This commit is contained in:
@@ -218,7 +218,7 @@ AttributeError</samp></pre>
|
||||
<td><a href=http://www.python.org/doc/3.0/reference/datamodel.html#object.__call__><code>my_instance.__call__()</code></a>
|
||||
</table>
|
||||
|
||||
<p>The <a href="http://docs.python.org/3.0/library/zipfile.html"><code>zipfile</code> module</a> uses this to define a class that can decrypt an encrypted zip file with a given password. The zip decryption algorithm requires you to store state during decryption. Defining the decryptor as a class allows you to maintain this state within a single instance of the decryptor class. The state is initialized in the <code>__init__()</code> method and updated as the file is decrypted. But since the class is also “callable” like a function, you can pass the instance as the first argument of the <code>map()</code> function, like so:
|
||||
<p>The <a href=http://docs.python.org/3.0/library/zipfile.html><code>zipfile</code> module</a> uses this to define a class that can decrypt an encrypted zip file with a given password. The zip decryption algorithm requires you to store state during decryption. Defining the decryptor as a class allows you to maintain this state within a single instance of the decryptor class. The state is initialized in the <code>__init__()</code> method and updated as the file is decrypted. But since the class is also “callable” like a function, you can pass the instance as the first argument of the <code>map()</code> function, like so:
|
||||
|
||||
<pre><code>
|
||||
# excerpt from zipfile.py
|
||||
|
||||
Reference in New Issue
Block a user