Browse Source

Tuple, Range, Iterator

pull/135/head
Jure Šorn 2 years ago
parent
commit
7994beb0e2
3 changed files with 21 additions and 29 deletions
  1. 20
      README.md
  2. 23
      index.html
  3. 7
      parse.js

20
README.md

@ -144,9 +144,9 @@ Tuple
-----
**Tuple is an immutable and hashable list.**
```python
<tuple> = () # Or: tuple()
<tuple> = (<el>,) # Or: <el>,
<tuple> = (<el_1>, <el_2> [, ...]) # Or: <el_1>, <el_2> [, ...]
<tuple> = () # Empty tuple.
<tuple> = (<el>,) # Or: <el>,
<tuple> = (<el_1>, <el_2> [, ...]) # Or: <el_1>, <el_2> [, ...]
```
### Named Tuple
@ -163,17 +163,17 @@ Point(x=1, y=2)
1
>>> getattr(p, 'y')
2
>>> p._fields # Or: Point._fields
('x', 'y')
```
Range
-----
**An immutable and hashable sequence of evenly spaced integers.**
```python
<range> = range(to_exclusive)
<range> = range(from_inclusive, to_exclusive)
<range> = range(from_inclusive, to_exclusive, ±step_size)
<range> = range(to_exclusive) # `list(range(3)) == [0, 1, 2]`
<range> = range(from_inclusive, to_exclusive) # `list(range(1, 4)) == [1, 2, 3]`
<range> = range(from_inclusive, to_exclusive, ±step) # `list(range(3, 0, -1)) == [3, 2, 1]`
```
```python
@ -212,12 +212,12 @@ from itertools import count, repeat, cycle, chain, islice
```python
<iter> = chain(<coll_1>, <coll_2> [, ...]) # Empties collections in order (figuratively).
<iter> = chain.from_iterable(<collection>) # Empties collections inside a collection in order.
<iter> = chain.from_iterable(<coll>) # Empties collections inside a collection in order.
```
```python
<iter> = islice(<coll>, to_exclusive) # Only returns first 'to_exclusive' elements.
<iter> = islice(<coll>, from_inclusive, …) # `to_exclusive, step_size`.
<iter> = islice(<coll>, from_inclusive, …) # `to_exclusive, +step`.
```

23
index.html

@ -54,7 +54,7 @@
<body>
<header>
<aside>June 27, 2022</aside>
<aside>July 13, 2022</aside>
<a href="https://gto76.github.io" rel="author">Jure Šorn</a>
</header>
@ -182,9 +182,9 @@ Counter({<span class="hljs-string">'blue'</span>: <span class="hljs-number">3</s
</code></pre></div>
<div><h2 id="tuple"><a href="#tuple" name="tuple">#</a>Tuple</h2><p><strong>Tuple is an immutable and hashable list.</strong></p><pre><code class="python language-python hljs">&lt;tuple&gt; = () <span class="hljs-comment"># Or: tuple()</span>
&lt;tuple&gt; = (&lt;el&gt;,) <span class="hljs-comment"># Or: &lt;el&gt;,</span>
&lt;tuple&gt; = (&lt;el_1&gt;, &lt;el_2&gt; [, ...]) <span class="hljs-comment"># Or: &lt;el_1&gt;, &lt;el_2&gt; [, ...]</span>
<div><h2 id="tuple"><a href="#tuple" name="tuple">#</a>Tuple</h2><p><strong>Tuple is an immutable and hashable list.</strong></p><pre><code class="python language-python hljs">&lt;tuple&gt; = () <span class="hljs-comment"># Empty tuple.</span>
&lt;tuple&gt; = (&lt;el&gt;,) <span class="hljs-comment"># Or: &lt;el&gt;,</span>
&lt;tuple&gt; = (&lt;el_1&gt;, &lt;el_2&gt; [, ...]) <span class="hljs-comment"># Or: &lt;el_1&gt;, &lt;el_2&gt; [, ...]</span>
</code></pre></div>
@ -198,16 +198,15 @@ Point(x=<span class="hljs-number">1</span>, y=<span class="hljs-number">2</span>
<span class="hljs-number">1</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>getattr(p, <span class="hljs-string">'y'</span>)
<span class="hljs-number">2</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>p._fields <span class="hljs-comment"># Or: Point._fields</span>
(<span class="hljs-string">'x'</span>, <span class="hljs-string">'y'</span>)
</code></pre></div>
<div><h2 id="range"><a href="#range" name="range">#</a>Range</h2><pre><code class="python language-python hljs">&lt;range&gt; = range(to_exclusive)
&lt;range&gt; = range(from_inclusive, to_exclusive)
&lt;range&gt; = range(from_inclusive, to_exclusive, ±step_size)
<div><h2 id="range"><a href="#range" name="range">#</a>Range</h2><p><strong>An immutable and hashable sequence of evenly spaced integers.</strong></p><pre><code class="python language-python hljs">&lt;range&gt; = range(to_exclusive) <span class="hljs-comment"># `list(range(3)) == [0, 1, 2]`</span>
&lt;range&gt; = range(from_inclusive, to_exclusive) <span class="hljs-comment"># `list(range(1, 4)) == [1, 2, 3]`</span>
&lt;range&gt; = range(from_inclusive, to_exclusive, ±step) <span class="hljs-comment"># `list(range(3, 0, -1)) == [3, 2, 1]`</span>
</code></pre></div>
<pre><code class="python language-python hljs">from_inclusive = &lt;range&gt;.start
to_exclusive = &lt;range&gt;.stop
</code></pre>
@ -229,10 +228,10 @@ to_exclusive = &lt;range&gt;.stop
&lt;iter&gt; = cycle(&lt;collection&gt;) <span class="hljs-comment"># Repeats the sequence endlessly.</span>
</code></pre>
<pre><code class="python language-python hljs">&lt;iter&gt; = chain(&lt;coll_1&gt;, &lt;coll_2&gt; [, ...]) <span class="hljs-comment"># Empties collections in order (figuratively).</span>
&lt;iter&gt; = chain.from_iterable(&lt;collection&gt;) <span class="hljs-comment"># Empties collections inside a collection in order.</span>
&lt;iter&gt; = chain.from_iterable(&lt;coll&gt;) <span class="hljs-comment"># Empties collections inside a collection in order.</span>
</code></pre>
<pre><code class="python language-python hljs">&lt;iter&gt; = islice(&lt;coll&gt;, to_exclusive) <span class="hljs-comment"># Only returns first 'to_exclusive' elements.</span>
&lt;iter&gt; = islice(&lt;coll&gt;, from_inclusive, …) <span class="hljs-comment"># `to_exclusive, step_size`.</span>
&lt;iter&gt; = islice(&lt;coll&gt;, from_inclusive, …) <span class="hljs-comment"># `to_exclusive, +step`.</span>
</code></pre>
<div><h2 id="generator"><a href="#generator" name="generator">#</a>Generator</h2><ul>
<li><strong>Any function that contains a yield statement returns a generator.</strong></li>
@ -2901,7 +2900,7 @@ $ pyinstaller script.py --add-data '&lt;path&gt;:.' <span class="hljs-comment">
<footer>
<aside>June 27, 2022</aside>
<aside>July 13, 2022</aside>
<a href="https://gto76.github.io" rel="author">Jure Šorn</a>
</footer>

7
parse.js

@ -794,13 +794,6 @@ function fixStructFormatDiv() {
$('#forstandardtypesizesandmanualalignmentpaddingstartformatstringwith').parent().insertBefore(div)
}
function fixStructFormat() {
const div = $('#format-2').parent()
$('#format-2').insertBefore(div)
$('#forstandardtypesizesandmanualalignmentpaddingstartformatstringwith').parent().insertBefore(div)
}
function updateDate(template) {
const date = new Date();
const date_str = date.toLocaleString('en-us', {month: 'long', day: 'numeric', year: 'numeric'});

Loading…
Cancel
Save