|
54 | 54 |
|
55 | 55 | <body>
|
56 | 56 | <header>
|
57 |
| - <aside>July 25, 2022</aside> |
| 57 | + <aside>July 26, 2022</aside> |
58 | 58 | <a href="https://gto76.github.io" rel="author">Jure Šorn</a>
|
59 | 59 | </header>
|
60 | 60 |
|
|
137 | 137 |
|
138 | 138 | <pre><code class="python language-python hljs">value = <dict>.get(key, default=<span class="hljs-keyword">None</span>) <span class="hljs-comment"># Returns default if key is missing.</span>
|
139 | 139 | value = <dict>.setdefault(key, default=<span class="hljs-keyword">None</span>) <span class="hljs-comment"># Returns and writes default if key is missing.</span>
|
140 |
| -<dict> = collections.defaultdict(<type>) <span class="hljs-comment"># Creates a dict with default value of type.</span> |
141 |
| -<dict> = collections.defaultdict(<span class="hljs-keyword">lambda</span>: <span class="hljs-number">1</span>) <span class="hljs-comment"># Creates a dict with default value 1.</span> |
| 140 | +<dict> = collections.defaultdict(<type>) <span class="hljs-comment"># Returns a dict with default value of type.</span> |
| 141 | +<dict> = collections.defaultdict(<span class="hljs-keyword">lambda</span>: <span class="hljs-number">1</span>) <span class="hljs-comment"># Returns a dict with default value 1.</span> |
142 | 142 | </code></pre>
|
143 | 143 | <pre><code class="python language-python hljs"><dict> = dict(<collection>) <span class="hljs-comment"># Creates a dict from coll. of key-value pairs.</span>
|
144 | 144 | <dict> = dict(zip(keys, values)) <span class="hljs-comment"># Creates a dict from two collections.</span>
|
|
158 | 158 | (<span class="hljs-string">'blue'</span>, <span class="hljs-number">3</span>)
|
159 | 159 | </code></pre></div>
|
160 | 160 |
|
161 |
| -<div><h2 id="set"><a href="#set" name="set">#</a>Set</h2><pre><code class="python language-python hljs"><set> = set() <span class="hljs-comment"># {} returns a dictionary.</span> |
| 161 | +<div><h2 id="set"><a href="#set" name="set">#</a>Set</h2><pre><code class="python language-python hljs"><set> = set() <span class="hljs-comment"># `{}` returns a dictionary.</span> |
162 | 162 | </code></pre></div>
|
163 | 163 |
|
164 | 164 | <pre><code class="python language-python hljs"><set>.add(<el>) <span class="hljs-comment"># Or: <set> |= {<el>}</span>
|
@@ -1700,7 +1700,7 @@ <h3 id="format-2">Format</h3><div><h4 id="forstandardtypesizesandmanualalignment
|
1700 | 1700 | </code></pre></div>
|
1701 | 1701 |
|
1702 | 1702 |
|
1703 |
| -<div><h3 id="decode-2">Decode</h3><pre><code class="python language-python hljs"><bytes> = bytes(<mview>) <span class="hljs-comment"># Creates a new bytes object.</span> |
| 1703 | +<div><h3 id="decode-2">Decode</h3><pre><code class="python language-python hljs"><bytes> = bytes(<mview>) <span class="hljs-comment"># Returns a new bytes object.</span> |
1704 | 1704 | <bytes> = <bytes>.join(<coll_of_mviews>) <span class="hljs-comment"># Joins mviews using bytes object as sep.</span>
|
1705 | 1705 | <array> = array(<span class="hljs-string">'<typecode>'</span>, <mview>) <span class="hljs-comment"># Treats mview as a sequence of numbers.</span>
|
1706 | 1706 | <file>.write(<mview>) <span class="hljs-comment"># Writes mview to the binary file.</span>
|
@@ -2905,7 +2905,7 @@ <h3 id="format-2">Format</h3><div><h4 id="forstandardtypesizesandmanualalignment
|
2905 | 2905 |
|
2906 | 2906 |
|
2907 | 2907 | <footer>
|
2908 |
| - <aside>July 25, 2022</aside> |
| 2908 | + <aside>July 26, 2022</aside> |
2909 | 2909 | <a href="https://gto76.github.io" rel="author">Jure Šorn</a>
|
2910 | 2910 | </footer>
|
2911 | 2911 |
|
|
0 commit comments