Browse Source

General fixes from List until Iterator

pull/52/merge
Jure Šorn 4 years ago
parent
commit
f58b9cc64a
3 changed files with 16 additions and 16 deletions
  1. 12
      README.md
  2. 10
      index.html
  3. 10
      pdf/index_for_pdf.html

12
README.md

@ -53,7 +53,7 @@ flatter_list = list(itertools.chain.from_iterable(<list>))
product_of_elems = functools.reduce(lambda out, el: out * el, <collection>)
list_of_chars = list(<str>)
```
* **Module [operator](#operator) provides functions itemgetter() and mul() that offer the same functionality as lambda expressions above.**
* **Module [operator](#operator) provides functions itemgetter() and mul() that offer the same functionality as [lambda](#lambda) expressions above.**
```python
<int> = <list>.count(<el>) # Returns number of occurrences. Also works on strings.
@ -205,7 +205,7 @@ from itertools import count, repeat, cycle, chain, islice
```
```python
<iter> = count(start=0, step=1) # Returns incremented value endlessly.
<iter> = count(start=0, step=1) # Returns updated value endlessly. Accepts floats.
<iter> = repeat(<el> [, times]) # Returns element endlessly or 'times' times.
<iter> = cycle(<collection>) # Repeats the sequence endlessly.
```
@ -261,8 +261,8 @@ Type
from types import FunctionType, MethodType, LambdaType, GeneratorType
```
### ABC
**An abstract base class introduces virtual subclasses that don’t inherit from it, but are still recognized by isinstance() and issubclass().**
### Abstract Base Classes
**Each abstract base class specifies a set of virtual subclasses. This classes get recognized by isinstance() and issubclass() as subclasses of the ABC, although they are really not.**
```python
>>> from collections.abc import Sequence, Collection, Iterable
@ -614,7 +614,7 @@ from dateutil.tz import UTC, tzlocal, gettz, resolve_imaginary
```python
<tzinfo> = UTC # UTC timezone. London without DST.
<tzinfo> = tzlocal() # Local timezone. Also gettz().
<tzinfo> = gettz('<Cont.>/<City>') # 'Continent/City_Name' timezone or None.
<tzinfo> = gettz('<Continent>/<City>') # 'Continent/City_Name' timezone or None.
<DTa> = <DT>.astimezone(<tzinfo>) # Datetime, converted to passed timezone.
<Ta/DTa> = <T/DT>.replace(tzinfo=<tzinfo>) # Unconverted object with new timezone.
```
@ -1106,7 +1106,7 @@ class MyHashable:
```
### Sortable
* **With total_ordering decorator you only need to provide eq() and one of lt(), gt(), le() or ge() special methods.**
* **With total_ordering decorator, you only need to provide eq() and one of lt(), gt(), le() or ge() special methods.**
```python
from functools import total_ordering

10
index.html

@ -250,7 +250,7 @@ product_of_elems = functools.reduce(<span class="hljs-keyword">lambda</span> out
list_of_chars = list(&lt;str&gt;)
</code></pre>
<ul>
<li><strong>Module <a href="#operator">operator</a> provides functions itemgetter() and mul() that offer the same functionality as lambda 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>
<pre><code class="python language-python hljs">&lt;int&gt; = &lt;list&gt;.count(&lt;el&gt;) <span class="hljs-comment"># Returns number of occurrences. Also works on strings.</span>
index = &lt;list&gt;.index(&lt;el&gt;) <span class="hljs-comment"># Returns index of first occurrence or raises ValueError.</span>
@ -353,7 +353,7 @@ to_exclusive = &lt;range&gt;.stop
<div><h3 id="itertools">Itertools</h3><pre><code class="python language-python hljs"><span class="hljs-keyword">from</span> itertools <span class="hljs-keyword">import</span> count, repeat, cycle, chain, islice
</code></pre></div>
<pre><code class="python language-python hljs">&lt;iter&gt; = count(start=<span class="hljs-number">0</span>, step=<span class="hljs-number">1</span>) <span class="hljs-comment"># Returns incremented value endlessly.</span>
<pre><code class="python language-python hljs">&lt;iter&gt; = 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; = repeat(&lt;el&gt; [, times]) <span class="hljs-comment"># Returns element endlessly or 'times' times.</span>
&lt;iter&gt; = cycle(&lt;collection&gt;) <span class="hljs-comment"># Repeats the sequence endlessly.</span>
</code></pre>
@ -392,7 +392,7 @@ to_exclusive = &lt;range&gt;.stop
<div><h4 id="sometypesdonothavebuiltinnamessotheymustbeimported">Some types do not have built-in names, so they must be imported:</h4><pre><code class="python language-python hljs"><span class="hljs-keyword">from</span> types <span class="hljs-keyword">import</span> FunctionType, MethodType, LambdaType, GeneratorType
</code></pre></div>
<div><h3 id="abc">ABC</h3><p><strong>An abstract base class introduces virtual subclasses that don’t inherit from it, but are still recognized by isinstance() and issubclass().</strong></p><pre><code class="python language-python hljs"><span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> collections.abc <span class="hljs-keyword">import</span> Sequence, Collection, Iterable
<div><h3 id="abstractbaseclasses">Abstract Base Classes</h3><p><strong>Each abstract base class specifies a set of virtual subclasses. This classes get recognized by isinstance() and issubclass() as subclasses of the ABC, although they are really not.</strong></p><pre><code class="python language-python hljs"><span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> collections.abc <span class="hljs-keyword">import</span> Sequence, Collection, Iterable
<span class="hljs-meta">&gt;&gt;&gt; </span>isinstance([<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>], Iterable)
<span class="hljs-keyword">True</span>
</code></pre></div>
@ -670,7 +670,7 @@ shuffle(&lt;list&gt;)
</ul>
<div><h3 id="timezone">Timezone</h3><pre><code class="python language-python apache hljs">&lt;tzinfo&gt; = UTC <span class="hljs-comment"># UTC timezone. London without DST.</span>
&lt;tzinfo&gt; = tzlocal() <span class="hljs-comment"># Local timezone. Also gettz().</span>
&lt;tzinfo&gt; = gettz(<span class="hljs-string">'&lt;Cont.&gt;/&lt;City&gt;'</span>) <span class="hljs-comment"># 'Continent/City_Name' timezone or None.</span>
&lt;tzinfo&gt; = gettz(<span class="hljs-string">'&lt;Continent&gt;/&lt;City&gt;'</span>) <span class="hljs-comment"># 'Continent/City_Name' timezone or None.</span>
&lt;DTa&gt; = &lt;DT&gt;.astimezone(&lt;tzinfo&gt;) <span class="hljs-comment"># Datetime, converted to passed timezone.</span>
&lt;Ta/DTa&gt; = &lt;T/DT&gt;.replace(tzinfo=&lt;tzinfo&gt;) <span class="hljs-comment"># Unconverted object with new timezone.</span>
</code></pre></div>
@ -1055,7 +1055,7 @@ Z = dataclasses.make_dataclass(<span class="hljs-string">'Z'</span>, [<span clas
<div><h3 id="sortable">Sortable</h3><ul>
<li><strong>With total_ordering decorator you only need to provide eq() and one of lt(), gt(), le() or ge() special methods.</strong></li>
<li><strong>With total_ordering decorator, you only need to provide eq() and one of lt(), gt(), le() or ge() special methods.</strong></li>
</ul><pre><code class="python language-python hljs"><span class="hljs-keyword">from</span> functools <span class="hljs-keyword">import</span> total_ordering
<span class="hljs-meta">@total_ordering</span>

10
pdf/index_for_pdf.html

@ -6,7 +6,7 @@
<div style="column-count: 3; width: 960px; page-break-inside: avoid">
<h3 id="a">A</h3>
<p><strong>abstract base classes, <a href="#abc">4</a>, <a href="#collectionsabcsequence">19</a></strong><br>
<p><strong>abstract base classes, <a href="#abstractbaseclasses">4</a>, <a href="#collectionsabcsequence">19</a></strong><br>
<strong>all function, <a href="#anyall">11</a></strong><br>
<strong>animation, <a href="#animation">40</a></strong><br>
<strong>any function, <a href="#anyall">11</a></strong><br>
@ -27,7 +27,7 @@
<strong>class, <a href="#type">4</a>, <a href="#class">14</a>-<a href="#collectionsabcsequence">19</a>, <a href="#metaprograming">31</a>-<a href="#metaclass">32</a></strong><br>
<strong>closure, <a href="#closure">12</a></strong><br>
<strong>collection, <a href="#type">4</a>, <a href="#collection">18</a></strong><br>
<strong>collections module, <a href="#counter">2</a>, <a href="#namedtuple">3</a>, <a href="#abc">4</a>, <a href="#collectionsabcsequence">19</a>, <a href="#deque">29</a></strong><br>
<strong>collections module, <a href="#counter">2</a>, <a href="#namedtuple">3</a>, <a href="#abstractbaseclasses">4</a>, <a href="#collectionsabcsequence">19</a>, <a href="#deque">29</a></strong><br>
<strong>combinatorics, <a href="#combinatorics">8</a></strong><br>
<strong>command line arguments, <a href="#commandlinearguments">22</a></strong><br>
<strong>comparable, <a href="#comparable">16</a></strong><br>
@ -53,7 +53,7 @@
<h3 id="f">F</h3>
<p><strong>files, <a href="#file">23</a></strong><br>
<strong>filter function, <a href="#mapfilterreduce">11</a></strong><br>
<strong>floats, <a href="#abc">4</a>, <a href="#floats">6</a>, <a href="#types">7</a></strong><br>
<strong>floats, <a href="#abstractbaseclasses">4</a>, <a href="#floats">6</a>, <a href="#types">7</a></strong><br>
<strong>format, <a href="#format">6</a>-<a href="#comparisonoffloatpresentationtypes">7</a></strong><br>
<strong>functools module, <a href="#mapfilterreduce">11</a>, <a href="#partial">12</a>, <a href="#decorator">13</a>, <a href="#sortable">16</a></strong><br>
<strong>futures, <a href="#threadpool">30</a></strong> </p>
@ -68,9 +68,9 @@
<strong>inline, <a href="#inline">11</a>-<a href="#namedtupleenumdataclass">12</a></strong><br>
<strong>input function, <a href="#input">22</a></strong><br>
<strong>introspection, <a href="#introspection">31</a></strong><br>
<strong>ints, <a href="#abc">4</a>, <a href="#types">7</a>, <a href="#binhex">8</a></strong><br>
<strong>ints, <a href="#abstractbaseclasses">4</a>, <a href="#types">7</a>, <a href="#binhex">8</a></strong><br>
<strong>is operator, <a href="#comparable">16</a></strong><br>
<strong>iterable, <a href="#abc">4</a>, <a href="#iterable">18</a></strong><br>
<strong>iterable, <a href="#abstractbaseclasses">4</a>, <a href="#iterable">18</a></strong><br>
<strong>iterator, <a href="#iterator">3</a>, <a href="#iterator-1">17</a></strong><br>
<strong>itertools module, <a href="#itertools">3</a>, <a href="#combinatorics">8</a></strong> </p>
<h3 id="j">J</h3>

Loading…
Cancel
Save