|
258 | 258 | </code></pre>
|
259 | 259 | <div><h2 id="dictionary"><a href="#dictionary" name="dictionary">#</a>Dictionary</h2><pre><code class="python language-python hljs"><view> = <dict>.keys() <span class="hljs-comment"># Coll. of keys that reflects changes.</span>
|
260 | 260 | <view> = <dict>.values() <span class="hljs-comment"># Coll. of values that reflects changes.</span>
|
261 |
| -<view> = <dict>.items() <span class="hljs-comment"># Coll. of key-value tuples.</span> |
| 261 | +<view> = <dict>.items() <span class="hljs-comment"># Coll. of key-value tuples that reflects chgs.</span> |
262 | 262 | </code></pre></div>
|
263 | 263 |
|
264 | 264 | <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>
|
|
378 | 378 | <li><strong>Everything is an object.</strong></li>
|
379 | 379 | <li><strong>Every object has a type.</strong></li>
|
380 | 380 | <li><strong>Type and class are synonymous.</strong></li>
|
381 |
| -</ul><pre><code class="python language-python hljs"><type> = type(<el>) <span class="hljs-comment"># Or: <el>.__class__</span> |
382 |
| -<bool> = isinstance(<el>, <type>) <span class="hljs-comment"># Or: issubclass(type(<el>), <type>)</span> |
| 381 | +</ul><pre><code class="python language-python hljs"><type> = type(<el>) <span class="hljs-comment"># Or: <el>.__class__</span> |
| 382 | +<bool> = isinstance(<el>, <type>) <span class="hljs-comment"># Or: issubclass(type(<el>), <type>)</span> |
383 | 383 | </code></pre></div>
|
384 | 384 |
|
385 | 385 |
|
|
473 | 473 | <li><strong>Use <code class="python hljs"><span class="hljs-string">r'\1'</span></code> or <code class="python hljs"><span class="hljs-string">'\\1'</span></code> for backreference.</strong></li>
|
474 | 474 | <li><strong>Add <code class="python hljs"><span class="hljs-string">'?'</span></code> after an operator to make it non-greedy.</strong></li>
|
475 | 475 | </ul>
|
476 |
| -<div><h3 id="matchobject">Match Object</h3><pre><code class="python language-python hljs"><str> = <Match>.group() <span class="hljs-comment"># Whole match. Also group(0).</span> |
477 |
| -<str> = <Match>.group(<span class="hljs-number">1</span>) <span class="hljs-comment"># Part in first bracket.</span> |
478 |
| -<tuple> = <Match>.groups() <span class="hljs-comment"># All bracketed parts.</span> |
479 |
| -<int> = <Match>.start() <span class="hljs-comment"># Start index of a match.</span> |
480 |
| -<int> = <Match>.end() <span class="hljs-comment"># Exclusive end index of a match.</span> |
| 476 | +<div><h3 id="matchobject">Match Object</h3><pre><code class="python language-python hljs"><str> = <Match>.group() <span class="hljs-comment"># Returns whole match. Also group(0).</span> |
| 477 | +<str> = <Match>.group(<span class="hljs-number">1</span>) <span class="hljs-comment"># Returns part in first bracket.</span> |
| 478 | +<tuple> = <Match>.groups() <span class="hljs-comment"># Returns all bracketed parts.</span> |
| 479 | +<int> = <Match>.start() <span class="hljs-comment"># Returns start index of a match.</span> |
| 480 | +<int> = <Match>.end() <span class="hljs-comment"># Returns exclusive end index of a match.</span> |
481 | 481 | </code></pre></div>
|
482 | 482 |
|
483 | 483 | <div><h3 id="specialsequences">Special Sequences</h3><ul>
|
|
558 | 558 | +---------------+-----------------+-----------------+-----------------+-----------------+
|
559 | 559 | </code></pre>
|
560 | 560 | <div><h3 id="ints">Ints</h3><pre><code class="python language-python hljs">{<span class="hljs-number">90</span>:c} <span class="hljs-comment"># 'Z'</span>
|
561 |
| -{<span class="hljs-number">90</span>:X} <span class="hljs-comment"># '5A'</span> |
562 | 561 | {<span class="hljs-number">90</span>:b} <span class="hljs-comment"># '1011010'</span>
|
| 562 | +{<span class="hljs-number">90</span>:X} <span class="hljs-comment"># '5A'</span> |
563 | 563 | </code></pre></div>
|
564 | 564 |
|
565 | 565 | <div><h2 id="numbers"><a href="#numbers" name="numbers">#</a>Numbers</h2><div><h3 id="types">Types</h3><pre><code class="python language-python hljs"><int> = int(<float/str/bool>) <span class="hljs-comment"># Or: math.floor(<float>)</span>
|
|
0 commit comments