Browse Source

Comment indentation fixes

pull/164/head
Jure Šorn 1 year ago
parent
commit
2f6477aa20
2 changed files with 64 additions and 64 deletions
  1. 62
      README.md
  2. 66
      index.html

62
README.md

@ -21,7 +21,7 @@ Contents
Main Main
---- ----
```python ```python
if __name__ == '__main__': # Runs main() if file wasn't imported.
if __name__ == '__main__': # Runs main() if file wasn't imported.
main() main()
``` ```
@ -29,19 +29,19 @@ if __name__ == '__main__': # Runs main() if file wasn't imported.
List List
---- ----
```python ```python
<list> = <list>[<slice>] # Or: <list>[from_inclusive : to_exclusive : ±step]
<list> = <list>[<slice>] # Or: <list>[from_inclusive : to_exclusive : ±step]
``` ```
```python ```python
<list>.append(<el>) # Or: <list> += [<el>]
<list>.extend(<collection>) # Or: <list> += <collection>
<list>.append(<el>) # Or: <list> += [<el>]
<list>.extend(<collection>) # Or: <list> += <collection>
``` ```
```python ```python
<list>.sort() # Sorts in ascending order.
<list>.reverse() # Reverses the list in-place.
<list> = sorted(<collection>) # Returns a new sorted list.
<iter> = reversed(<list>) # Returns reversed iterator.
<list>.sort() # Sorts in ascending order.
<list>.reverse() # Reverses the list in-place.
<list> = sorted(<collection>) # Returns a new sorted list.
<iter> = reversed(<list>) # Returns reversed iterator.
``` ```
```python ```python
@ -57,12 +57,12 @@ list_of_chars = list(<str>)
* **Module [operator](#operator) provides functions itemgetter() and mul() that offer the same functionality as [lambda](#lambda) expressions above.** * **Module [operator](#operator) provides functions itemgetter() and mul() that offer the same functionality as [lambda](#lambda) expressions above.**
```python ```python
<list>.insert(<int>, <el>) # Inserts item at index and moves the rest to the right.
<el> = <list>.pop([<int>]) # Removes and returns item at index or from the end.
<int> = <list>.count(<el>) # Returns number of occurrences. Also works on strings.
<int> = <list>.index(<el>) # Returns index of the first occurrence or raises ValueError.
<list>.remove(<el>) # Removes first occurrence of the item or raises ValueError.
<list>.clear() # Removes all items. Also works on dictionary and set.
<list>.insert(<int>, <el>) # Inserts item at index and moves the rest to the right.
<el> = <list>.pop([<int>]) # Removes and returns item at index or from the end.
<int> = <list>.count(<el>) # Returns number of occurrences. Also works on strings.
<int> = <list>.index(<el>) # Returns index of the first occurrence or raises ValueError.
<list>.remove(<el>) # Removes first occurrence of the item or raises ValueError.
<list>.clear() # Removes all items. Also works on dictionary and set.
``` ```
@ -144,9 +144,9 @@ Tuple
----- -----
**Tuple is an immutable and hashable list.** **Tuple is an immutable and hashable list.**
```python ```python
<tuple> = () # Empty 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 ### Named Tuple
@ -170,9 +170,9 @@ Range
----- -----
**Immutable and hashable sequence of integers.** **Immutable and hashable sequence of integers.**
```python ```python
<range> = range(stop) # range(to_exclusive)
<range> = range(start, stop) # range(from_inclusive, to_exclusive)
<range> = range(start, stop, ±step) # range(from_inclusive, to_exclusive, ±step_size)
<range> = range(stop) # range(to_exclusive)
<range> = range(start, stop) # range(from_inclusive, to_exclusive)
<range> = range(start, stop, ±step) # range(from_inclusive, to_exclusive, ±step_size)
``` ```
```python ```python
@ -192,10 +192,10 @@ for i, el in enumerate(<collection> [, i_start]):
Iterator Iterator
-------- --------
```python ```python
<iter> = iter(<collection>) # `iter(<iter>)` returns unmodified iterator.
<iter> = iter(<function>, to_exclusive) # A sequence of return values until 'to_exclusive'.
<el> = next(<iter> [, default]) # Raises StopIteration or returns 'default' on end.
<list> = list(<iter>) # Returns a list of iterator's remaining elements.
<iter> = iter(<collection>) # `iter(<iter>)` returns unmodified iterator.
<iter> = iter(<function>, to_exclusive) # A sequence of return values until 'to_exclusive'.
<el> = next(<iter> [, default]) # Raises StopIteration or returns 'default' on end.
<list> = list(<iter>) # Returns a list of iterator's remaining elements.
``` ```
### Itertools ### Itertools
@ -204,19 +204,19 @@ import itertools as it
``` ```
```python ```python
<iter> = it.count(start=0, step=1) # Returns updated value endlessly. Accepts floats.
<iter> = it.repeat(<el> [, times]) # Returns element endlessly or 'times' times.
<iter> = it.cycle(<collection>) # Repeats the sequence endlessly.
<iter> = it.count(start=0, step=1) # Returns updated value endlessly. Accepts floats.
<iter> = it.repeat(<el> [, times]) # Returns element endlessly or 'times' times.
<iter> = it.cycle(<collection>) # Repeats the sequence endlessly.
``` ```
```python ```python
<iter> = it.chain(<coll>, <coll> [, ...]) # Empties collections in order (figuratively).
<iter> = it.chain.from_iterable(<coll>) # Empties collections inside a collection in order.
<iter> = it.chain(<coll>, <coll> [, ...]) # Empties collections in order (figuratively).
<iter> = it.chain.from_iterable(<coll>) # Empties collections inside a collection in order.
``` ```
```python ```python
<iter> = it.islice(<coll>, to_exclusive) # Only returns first 'to_exclusive' elements.
<iter> = it.islice(<coll>, from_inc, …) # `to_exclusive, +step_size`. Indices can be None.
<iter> = it.islice(<coll>, to_exclusive) # Only returns first 'to_exclusive' elements.
<iter> = it.islice(<coll>, from_inc, …) # `to_exclusive, +step_size`. Indices can be None.
``` ```

66
index.html

@ -54,7 +54,7 @@
<body> <body>
<header> <header>
<aside>August 2, 2023</aside>
<aside>August 3, 2023</aside>
<a href="https://gto76.github.io" rel="author">Jure Šorn</a> <a href="https://gto76.github.io" rel="author">Jure Šorn</a>
</header> </header>
@ -96,20 +96,20 @@
<div><h2 id="main"><a href="#main" name="main">#</a>Main</h2><pre><code class="python language-python hljs"><span class="hljs-keyword">if</span> __name__ == <span class="hljs-string">'__main__'</span>: <span class="hljs-comment"># Runs main() if file wasn't imported.</span>
<div><h2 id="main"><a href="#main" name="main">#</a>Main</h2><pre><code class="python language-python hljs"><span class="hljs-keyword">if</span> __name__ == <span class="hljs-string">'__main__'</span>: <span class="hljs-comment"># Runs main() if file wasn't imported.</span>
main() main()
</code></pre></div> </code></pre></div>
<div><h2 id="list"><a href="#list" name="list">#</a>List</h2><pre><code class="python language-python hljs">&lt;list&gt; = &lt;list&gt;[&lt;slice&gt;] <span class="hljs-comment"># Or: &lt;list&gt;[from_inclusive : to_exclusive : ±step]</span>
<div><h2 id="list"><a href="#list" name="list">#</a>List</h2><pre><code class="python language-python hljs">&lt;list&gt; = &lt;list&gt;[&lt;slice&gt;] <span class="hljs-comment"># Or: &lt;list&gt;[from_inclusive : to_exclusive : ±step]</span>
</code></pre></div> </code></pre></div>
<pre><code class="python language-python hljs">&lt;list&gt;.append(&lt;el&gt;) <span class="hljs-comment"># Or: &lt;list&gt; += [&lt;el&gt;]</span>
&lt;list&gt;.extend(&lt;collection&gt;) <span class="hljs-comment"># Or: &lt;list&gt; += &lt;collection&gt;</span>
<pre><code class="python language-python hljs">&lt;list&gt;.append(&lt;el&gt;) <span class="hljs-comment"># Or: &lt;list&gt; += [&lt;el&gt;]</span>
&lt;list&gt;.extend(&lt;collection&gt;) <span class="hljs-comment"># Or: &lt;list&gt; += &lt;collection&gt;</span>
</code></pre> </code></pre>
<pre><code class="python language-python hljs">&lt;list&gt;.sort() <span class="hljs-comment"># Sorts in ascending order.</span>
&lt;list&gt;.reverse() <span class="hljs-comment"># Reverses the list in-place.</span>
&lt;list&gt; = sorted(&lt;collection&gt;) <span class="hljs-comment"># Returns a new sorted list.</span>
&lt;iter&gt; = reversed(&lt;list&gt;) <span class="hljs-comment"># Returns reversed iterator.</span>
<pre><code class="python language-python hljs">&lt;list&gt;.sort() <span class="hljs-comment"># Sorts in ascending order.</span>
&lt;list&gt;.reverse() <span class="hljs-comment"># Reverses the list in-place.</span>
&lt;list&gt; = sorted(&lt;collection&gt;) <span class="hljs-comment"># Returns a new sorted list.</span>
&lt;iter&gt; = reversed(&lt;list&gt;) <span class="hljs-comment"># Returns reversed iterator.</span>
</code></pre> </code></pre>
<pre><code class="python language-python hljs">sum_of_elements = sum(&lt;collection&gt;) <pre><code class="python language-python hljs">sum_of_elements = sum(&lt;collection&gt;)
elementwise_sum = [sum(pair) <span class="hljs-keyword">for</span> pair <span class="hljs-keyword">in</span> zip(list_a, list_b)] elementwise_sum = [sum(pair) <span class="hljs-keyword">for</span> pair <span class="hljs-keyword">in</span> zip(list_a, list_b)]
@ -123,12 +123,12 @@ list_of_chars = list(&lt;str&gt;)
<li><strong>For details about sorted(), min() and max() see <a href="#sortable">sortable</a>.</strong></li> <li><strong>For details about sorted(), min() and max() see <a href="#sortable">sortable</a>.</strong></li>
<li><strong>Module <a href="#operator">operator</a> provides functions itemgetter() and mul() that offer the same functionality as <a href="#lambda">lambda</a> expressions above.</strong></li> <li><strong>Module <a href="#operator">operator</a> provides functions itemgetter() and mul() that offer the same functionality as <a href="#lambda">lambda</a> expressions above.</strong></li>
</ul> </ul>
<pre><code class="python language-python hljs">&lt;list&gt;.insert(&lt;int&gt;, &lt;el&gt;) <span class="hljs-comment"># Inserts item at index and moves the rest to the right.</span>
&lt;el&gt; = &lt;list&gt;.pop([&lt;int&gt;]) <span class="hljs-comment"># Removes and returns item at index or from the end.</span>
&lt;int&gt; = &lt;list&gt;.count(&lt;el&gt;) <span class="hljs-comment"># Returns number of occurrences. Also works on strings.</span>
&lt;int&gt; = &lt;list&gt;.index(&lt;el&gt;) <span class="hljs-comment"># Returns index of the first occurrence or raises ValueError.</span>
&lt;list&gt;.remove(&lt;el&gt;) <span class="hljs-comment"># Removes first occurrence of the item or raises ValueError.</span>
&lt;list&gt;.clear() <span class="hljs-comment"># Removes all items. Also works on dictionary and set.</span>
<pre><code class="python language-python hljs">&lt;list&gt;.insert(&lt;int&gt;, &lt;el&gt;) <span class="hljs-comment"># Inserts item at index and moves the rest to the right.</span>
&lt;el&gt; = &lt;list&gt;.pop([&lt;int&gt;]) <span class="hljs-comment"># Removes and returns item at index or from the end.</span>
&lt;int&gt; = &lt;list&gt;.count(&lt;el&gt;) <span class="hljs-comment"># Returns number of occurrences. Also works on strings.</span>
&lt;int&gt; = &lt;list&gt;.index(&lt;el&gt;) <span class="hljs-comment"># Returns index of the first occurrence or raises ValueError.</span>
&lt;list&gt;.remove(&lt;el&gt;) <span class="hljs-comment"># Removes first occurrence of the item or raises ValueError.</span>
&lt;list&gt;.clear() <span class="hljs-comment"># Removes all items. Also works on dictionary and set.</span>
</code></pre> </code></pre>
<div><h2 id="dictionary"><a href="#dictionary" name="dictionary">#</a>Dictionary</h2><pre><code class="python language-python hljs">&lt;view&gt; = &lt;dict&gt;.keys() <span class="hljs-comment"># Coll. of keys that reflects changes.</span> <div><h2 id="dictionary"><a href="#dictionary" name="dictionary">#</a>Dictionary</h2><pre><code class="python language-python hljs">&lt;view&gt; = &lt;dict&gt;.keys() <span class="hljs-comment"># Coll. of keys that reflects changes.</span>
&lt;view&gt; = &lt;dict&gt;.values() <span class="hljs-comment"># Coll. of values that reflects changes.</span> &lt;view&gt; = &lt;dict&gt;.values() <span class="hljs-comment"># Coll. of values that reflects changes.</span>
@ -182,9 +182,9 @@ Counter({<span class="hljs-string">'blue'</span>: <span class="hljs-number">3</s
</code></pre></div> </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"># 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>
<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> </code></pre></div>
@ -201,9 +201,9 @@ Point(x=<span class="hljs-number">1</span>, y=<span class="hljs-number">2</span>
</code></pre></div> </code></pre></div>
<div><h2 id="range"><a href="#range" name="range">#</a>Range</h2><p><strong>Immutable and hashable sequence of integers.</strong></p><pre><code class="python language-python hljs">&lt;range&gt; = range(stop) <span class="hljs-comment"># range(to_exclusive)</span>
&lt;range&gt; = range(start, stop) <span class="hljs-comment"># range(from_inclusive, to_exclusive)</span>
&lt;range&gt; = range(start, stop, ±step) <span class="hljs-comment"># range(from_inclusive, to_exclusive, ±step_size)</span>
<div><h2 id="range"><a href="#range" name="range">#</a>Range</h2><p><strong>Immutable and hashable sequence of integers.</strong></p><pre><code class="python language-python hljs">&lt;range&gt; = range(stop) <span class="hljs-comment"># range(to_exclusive)</span>
&lt;range&gt; = range(start, stop) <span class="hljs-comment"># range(from_inclusive, to_exclusive)</span>
&lt;range&gt; = range(start, stop, ±step) <span class="hljs-comment"># range(from_inclusive, to_exclusive, ±step_size)</span>
</code></pre></div> </code></pre></div>
@ -214,24 +214,24 @@ Point(x=<span class="hljs-number">1</span>, y=<span class="hljs-number">2</span>
... ...
</code></pre></div> </code></pre></div>
<div><h2 id="iterator"><a href="#iterator" name="iterator">#</a>Iterator</h2><pre><code class="python language-python hljs">&lt;iter&gt; = iter(&lt;collection&gt;) <span class="hljs-comment"># `iter(&lt;iter&gt;)` returns unmodified iterator.</span>
&lt;iter&gt; = iter(&lt;function&gt;, to_exclusive) <span class="hljs-comment"># A sequence of return values until 'to_exclusive'.</span>
&lt;el&gt; = next(&lt;iter&gt; [, default]) <span class="hljs-comment"># Raises StopIteration or returns 'default' on end.</span>
&lt;list&gt; = list(&lt;iter&gt;) <span class="hljs-comment"># Returns a list of iterator's remaining elements.</span>
<div><h2 id="iterator"><a href="#iterator" name="iterator">#</a>Iterator</h2><pre><code class="python language-python hljs">&lt;iter&gt; = iter(&lt;collection&gt;) <span class="hljs-comment"># `iter(&lt;iter&gt;)` returns unmodified iterator.</span>
&lt;iter&gt; = iter(&lt;function&gt;, to_exclusive) <span class="hljs-comment"># A sequence of return values until 'to_exclusive'.</span>
&lt;el&gt; = next(&lt;iter&gt; [, default]) <span class="hljs-comment"># Raises StopIteration or returns 'default' on end.</span>
&lt;list&gt; = list(&lt;iter&gt;) <span class="hljs-comment"># Returns a list of iterator's remaining elements.</span>
</code></pre></div> </code></pre></div>
<div><h3 id="itertools">Itertools</h3><pre><code class="python language-python hljs"><span class="hljs-keyword">import</span> itertools <span class="hljs-keyword">as</span> it <div><h3 id="itertools">Itertools</h3><pre><code class="python language-python hljs"><span class="hljs-keyword">import</span> itertools <span class="hljs-keyword">as</span> it
</code></pre></div> </code></pre></div>
<pre><code class="python language-python hljs">&lt;iter&gt; = it.count(start=<span class="hljs-number">0</span>, step=<span class="hljs-number">1</span>) <span class="hljs-comment"># Returns updated value endlessly. Accepts floats.</span>
&lt;iter&gt; = it.repeat(&lt;el&gt; [, times]) <span class="hljs-comment"># Returns element endlessly or 'times' times.</span>
&lt;iter&gt; = it.cycle(&lt;collection&gt;) <span class="hljs-comment"># Repeats the sequence endlessly.</span>
<pre><code class="python language-python hljs">&lt;iter&gt; = it.count(start=<span class="hljs-number">0</span>, step=<span class="hljs-number">1</span>) <span class="hljs-comment"># Returns updated value endlessly. Accepts floats.</span>
&lt;iter&gt; = it.repeat(&lt;el&gt; [, times]) <span class="hljs-comment"># Returns element endlessly or 'times' times.</span>
&lt;iter&gt; = it.cycle(&lt;collection&gt;) <span class="hljs-comment"># Repeats the sequence endlessly.</span>
</code></pre> </code></pre>
<pre><code class="python language-python hljs">&lt;iter&gt; = it.chain(&lt;coll&gt;, &lt;coll&gt; [, ...]) <span class="hljs-comment"># Empties collections in order (figuratively).</span>
&lt;iter&gt; = it.chain.from_iterable(&lt;coll&gt;) <span class="hljs-comment"># Empties collections inside a collection in order.</span>
<pre><code class="python language-python hljs">&lt;iter&gt; = it.chain(&lt;coll&gt;, &lt;coll&gt; [, ...]) <span class="hljs-comment"># Empties collections in order (figuratively).</span>
&lt;iter&gt; = it.chain.from_iterable(&lt;coll&gt;) <span class="hljs-comment"># Empties collections inside a collection in order.</span>
</code></pre> </code></pre>
<pre><code class="python language-python hljs">&lt;iter&gt; = it.islice(&lt;coll&gt;, to_exclusive) <span class="hljs-comment"># Only returns first 'to_exclusive' elements.</span>
&lt;iter&gt; = it.islice(&lt;coll&gt;, from_inc, …) <span class="hljs-comment"># `to_exclusive, +step_size`. Indices can be None.</span>
<pre><code class="python language-python hljs">&lt;iter&gt; = it.islice(&lt;coll&gt;, to_exclusive) <span class="hljs-comment"># Only returns first 'to_exclusive' elements.</span>
&lt;iter&gt; = it.islice(&lt;coll&gt;, from_inc, …) <span class="hljs-comment"># `to_exclusive, +step_size`. Indices can be None.</span>
</code></pre> </code></pre>
<div><h2 id="generator"><a href="#generator" name="generator">#</a>Generator</h2><ul> <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> <li><strong>Any function that contains a yield statement returns a generator.</strong></li>
@ -2930,7 +2930,7 @@ $ deactivate <span class="hljs-comment"># Deactivates virtual e
<footer> <footer>
<aside>August 2, 2023</aside>
<aside>August 3, 2023</aside>
<a href="https://gto76.github.io" rel="author">Jure Šorn</a> <a href="https://gto76.github.io" rel="author">Jure Šorn</a>
</footer> </footer>

Loading…
Cancel
Save