|
271 | 271 | <dict> = dict(zip(keys, values)) <span class="hljs-comment"># Creates a dict from two collections.</span>
|
272 | 272 | <dict> = dict.fromkeys(keys [, value]) <span class="hljs-comment"># Creates a dict from collection of keys.</span>
|
273 | 273 | </code></pre>
|
274 |
| -<pre><code class="python language-python hljs">value = <dict>.pop(key) <span class="hljs-comment"># Removes item from dictionary.</span> |
| 274 | +<pre><code class="python language-python hljs">value = <dict>.pop(key) <span class="hljs-comment"># Removes item or raises KeyError.</span> |
275 | 275 | {k: v <span class="hljs-keyword">for</span> k, v <span class="hljs-keyword">in</span> <dict>.items() <span class="hljs-keyword">if</span> k <span class="hljs-keyword">in</span> keys} <span class="hljs-comment"># Filters dictionary by keys.</span>
|
276 | 276 | </code></pre>
|
277 | 277 | <div><h3 id="counter">Counter</h3><pre><code class="python language-python hljs"><span class="hljs-meta">>>> </span><span class="hljs-keyword">from</span> collections <span class="hljs-keyword">import</span> Counter
|
|
459 | 459 | </code></pre></div>
|
460 | 460 |
|
461 | 461 | <ul>
|
| 462 | +<li><strong>Search() and match() return None if there are no matches.</strong></li> |
462 | 463 | <li><strong>Argument <code class="python hljs"><span class="hljs-string">'flags=re.IGNORECASE'</span></code> can be used with all functions.</strong></li>
|
463 | 464 | <li><strong>Argument <code class="python hljs"><span class="hljs-string">'flags=re.MULTILINE'</span></code> makes <code class="python hljs"><span class="hljs-string">'^'</span></code> and <code class="python hljs"><span class="hljs-string">'$'</span></code> match the start/end of each line.</strong></li>
|
464 | 465 | <li><strong>Argument <code class="python hljs"><span class="hljs-string">'flags=re.DOTALL'</span></code> makes dot also accept newline.</strong></li>
|
|
660 | 661 | </ul>
|
661 | 662 | <div><h3 id="timezone">Timezone</h3><pre><code class="python language-python hljs"><tzinfo> = UTC <span class="hljs-comment"># UTC timezone. London without DST.</span>
|
662 | 663 | <tzinfo> = tzlocal() <span class="hljs-comment"># Local timezone. Also gettz().</span>
|
663 |
| -<tzinfo> = gettz(<span class="hljs-string">'<Cont.>/<City>'</span>) <span class="hljs-comment"># Timezone from 'Continent/City_Name' str.</span> |
| 664 | +<tzinfo> = gettz(<span class="hljs-string">'<Cont.>/<City>'</span>) <span class="hljs-comment"># 'Continent/City_Name' timezone or None.</span> |
664 | 665 | </code></pre></div>
|
665 | 666 |
|
666 | 667 | <pre><code class="python language-python apache hljs"><DTa> = <DT>.astimezone(<tzinfo>) <span class="hljs-comment"># Datetime, converted to passed timezone.</span>
|
667 | 668 | <Ta/DTa> = <T/DT>.replace(tzinfo=<tzinfo>) <span class="hljs-comment"># Unconverted object with new timezone.</span>
|
668 | 669 | </code></pre>
|
669 |
| -<div><h3 id="encode">Encode</h3><pre><code class="python language-python apache hljs"><D/T/DT> = D/T/DT.fromisoformat(<span class="hljs-string">'<iso>'</span>) <span class="hljs-comment"># Object from ISO string.</span> |
670 |
| -<DT> = DT.strptime(<str>, <span class="hljs-string">'<format>'</span>) <span class="hljs-comment"># Datetime from str, according to format.</span> |
| 670 | +<div><h3 id="encode">Encode</h3><pre><code class="python language-python apache hljs"><D/T/DT> = D/T/DT.fromisoformat(<span class="hljs-string">'<iso>'</span>) <span class="hljs-comment"># Object from ISO string. Raises ValueError.</span> |
| 671 | +<DT> = DT.strptime(<str>, <span class="hljs-string">'<format>'</span>) <span class="hljs-comment"># Datetime from str, according to format. </span> |
671 | 672 | <D/DTn> = D/DT.fromordinal(<int>) <span class="hljs-comment"># D/DTn from days since Christ, at midnight.</span>
|
672 | 673 | <DTn> = DT.fromtimestamp(<real>) <span class="hljs-comment"># Local time DTn from seconds since Epoch.</span>
|
673 | 674 | <DTa> = DT.fromtimestamp(<real>, <tz.>) <span class="hljs-comment"># Aware datetime from seconds since Epoch.</span>
|
|
1218 | 1219 | <li><strong>If there are no numeric values before auto(), it returns 1.</strong></li>
|
1219 | 1220 | <li><strong>Otherwise it returns an increment of last numeric value.</strong></li>
|
1220 | 1221 | </ul>
|
1221 |
| -<pre><code class="python language-python hljs"><member> = <enum>.<member_name> |
1222 |
| -<member> = <enum>[<span class="hljs-string">'<member_name>'</span>] |
1223 |
| -<member> = <enum>(<value>) |
| 1222 | +<pre><code class="python language-python hljs"><member> = <enum>.<member_name> <span class="hljs-comment"># Returns a member.</span> |
| 1223 | +<member> = <enum>[<span class="hljs-string">'<member_name>'</span>] <span class="hljs-comment"># Returns a member or raises KeyError.</span> |
| 1224 | +<member> = <enum>(<value>) <span class="hljs-comment"># Returns a member or raises ValueError.</span> |
1224 | 1225 | name = <member>.name
|
1225 | 1226 | value = <member>.value
|
1226 | 1227 | </code></pre>
|
|
0 commit comments