Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit dd37505

Browse files
committed
Inline
1 parent 1fa9a99 commit dd37505

File tree

2 files changed

+24
-24
lines changed

2 files changed

+24
-24
lines changed

README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -732,10 +732,10 @@ def f(x, *args, z, **kwargs): # f(x=1, y=2, z=3) | f(1, y=2, z=3) | f(1, 2, z=3
732732

733733
### Other Uses
734734
```python
735-
<list> = [*<collection> [, ...]]
736-
<set> = {*<collection> [, ...]}
737-
<tup.> = (*<collection>, [...])
738-
<dict> = {**<dict> [, ...]}
735+
<list> = [*<collection> [, ...]]
736+
<set> = {*<collection> [, ...]}
737+
<tuple> = (*<collection>, [...])
738+
<dict> = {**<dict> [, ...]}
739739
```
740740

741741
```python
@@ -774,8 +774,8 @@ Inline
774774

775775
### Any, All
776776
```python
777-
<bool> = any(<collection>) # False if empty.
778-
<bool> = all(el[1] for el in <collection>) # True if empty.
777+
<bool> = any(<collection>) # Is `bool(el)` True for any element.
778+
<bool> = all(<collection>) # Is True for all elements or empty.
779779
```
780780

781781
### Conditional Expression
@@ -788,11 +788,11 @@ Inline
788788
['zero', 1, 2, 3]
789789
```
790790

791-
### Namedtuple, Enum, Dataclass
791+
### Named Tuple, Enum, Dataclass
792792
```python
793793
from collections import namedtuple
794-
Point = namedtuple('Point', 'x y')
795-
point = Point(0, 0)
794+
Point = namedtuple('Point', 'x y')
795+
point = Point(0, 0)
796796
```
797797

798798
```python
@@ -803,8 +803,8 @@ direction = Direction.n
803803

804804
```python
805805
from dataclasses import make_dataclass
806-
Creature = make_dataclass('Creature', ['loc', 'dir'])
807-
creature = Creature(Point(0, 0), Direction.n)
806+
Creature = make_dataclass('Creature', ['loc', 'dir'])
807+
creature = Creature(point, direction)
808808
```
809809

810810

index.html

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@
226226

227227
<body>
228228
<header>
229-
<aside>August 11, 2021</aside>
229+
<aside>October 1, 2021</aside>
230230
<a href="https://gto76.github.io" rel="author">Jure Šorn</a>
231231
</header>
232232

@@ -786,10 +786,10 @@
786786
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">f</span><span class="hljs-params">(*args, y, **kwargs)</span>:</span> <span class="hljs-comment"># f(x=1, y=2, z=3) | f(1, y=2, z=3)</span>
787787
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">f</span><span class="hljs-params">(x, *args, z, **kwargs)</span>:</span> <span class="hljs-comment"># f(x=1, y=2, z=3) | f(1, y=2, z=3) | f(1, 2, z=3)</span>
788788
</code></pre>
789-
<div><h3 id="otheruses">Other Uses</h3><pre><code class="python language-python hljs">&lt;list&gt; = [*&lt;collection&gt; [, ...]]
790-
&lt;set&gt; = {*&lt;collection&gt; [, ...]}
791-
&lt;tup.&gt; = (*&lt;collection&gt;, [...])
792-
&lt;dict&gt; = {**&lt;dict&gt; [, ...]}
789+
<div><h3 id="otheruses">Other Uses</h3><pre><code class="python language-python hljs">&lt;list&gt; = [*&lt;collection&gt; [, ...]]
790+
&lt;set&gt; = {*&lt;collection&gt; [, ...]}
791+
&lt;tuple&gt; = (*&lt;collection&gt;, [...])
792+
&lt;dict&gt; = {**&lt;dict&gt; [, ...]}
793793
</code></pre></div>
794794

795795
<pre><code class="python language-python hljs">head, *body, tail = &lt;collection&gt;
@@ -816,8 +816,8 @@
816816
<ul>
817817
<li><strong>Reduce must be imported from functools module.</strong></li>
818818
</ul>
819-
<div><h3 id="anyall">Any, All</h3><pre><code class="python language-python hljs">&lt;bool&gt; = any(&lt;collection&gt;) <span class="hljs-comment"># False if empty.</span>
820-
&lt;bool&gt; = all(el[<span class="hljs-number">1</span>] <span class="hljs-keyword">for</span> el <span class="hljs-keyword">in</span> &lt;collection&gt;) <span class="hljs-comment"># True if empty.</span>
819+
<div><h3 id="anyall">Any, All</h3><pre><code class="python language-python hljs">&lt;bool&gt; = any(&lt;collection&gt;) <span class="hljs-comment"># Is `bool(el)` True for any element.</span>
820+
&lt;bool&gt; = all(&lt;collection&gt;) <span class="hljs-comment"># Is True for all elements or empty.</span>
821821
</code></pre></div>
822822

823823
<div><h3 id="conditionalexpression">Conditional Expression</h3><pre><code class="python language-python hljs">&lt;obj&gt; = &lt;exp_if_true&gt; <span class="hljs-keyword">if</span> &lt;condition&gt; <span class="hljs-keyword">else</span> &lt;exp_if_false&gt;
@@ -826,18 +826,18 @@
826826
<pre><code class="python language-python hljs"><span class="hljs-meta">&gt;&gt;&gt; </span>[a <span class="hljs-keyword">if</span> a <span class="hljs-keyword">else</span> <span class="hljs-string">'zero'</span> <span class="hljs-keyword">for</span> a <span class="hljs-keyword">in</span> (<span class="hljs-number">0</span>, <span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>)]
827827
[<span class="hljs-string">'zero'</span>, <span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>]
828828
</code></pre>
829-
<div><h3 id="namedtupleenumdataclass">Namedtuple, Enum, Dataclass</h3><pre><code class="python language-python hljs"><span class="hljs-keyword">from</span> collections <span class="hljs-keyword">import</span> namedtuple
830-
Point = namedtuple(<span class="hljs-string">'Point'</span>, <span class="hljs-string">'x y'</span>)
831-
point = Point(<span class="hljs-number">0</span>, <span class="hljs-number">0</span>)
829+
<div><h3 id="namedtupleenumdataclass">Named Tuple, Enum, Dataclass</h3><pre><code class="python language-python hljs"><span class="hljs-keyword">from</span> collections <span class="hljs-keyword">import</span> namedtuple
830+
Point = namedtuple(<span class="hljs-string">'Point'</span>, <span class="hljs-string">'x y'</span>)
831+
point = Point(<span class="hljs-number">0</span>, <span class="hljs-number">0</span>)
832832
</code></pre></div>
833833

834834
<pre><code class="python language-python hljs"><span class="hljs-keyword">from</span> enum <span class="hljs-keyword">import</span> Enum
835835
Direction = Enum(<span class="hljs-string">'Direction'</span>, <span class="hljs-string">'n e s w'</span>)
836836
direction = Direction.n
837837
</code></pre>
838838
<pre><code class="python language-python hljs"><span class="hljs-keyword">from</span> dataclasses <span class="hljs-keyword">import</span> make_dataclass
839-
Creature = make_dataclass(<span class="hljs-string">'Creature'</span>, [<span class="hljs-string">'loc'</span>, <span class="hljs-string">'dir'</span>])
840-
creature = Creature(Point(<span class="hljs-number">0</span>, <span class="hljs-number">0</span>), Direction.n)
839+
Creature = make_dataclass(<span class="hljs-string">'Creature'</span>, [<span class="hljs-string">'loc'</span>, <span class="hljs-string">'dir'</span>])
840+
creature = Creature(point, direction)
841841
</code></pre>
842842
<div><h2 id="closure"><a href="#closure" name="closure">#</a>Closure</h2><p><strong>We have a closure in Python when:</strong></p><ul>
843843
<li><strong>A nested function references a value of its enclosing function and then</strong></li>
@@ -3005,7 +3005,7 @@
30053005

30063006

30073007
<footer>
3008-
<aside>August 11, 2021</aside>
3008+
<aside>October 1, 2021</aside>
30093009
<a href="https://gto76.github.io" rel="author">Jure Šorn</a>
30103010
</footer>
30113011

0 commit comments

Comments
 (0)