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

Skip to content

Commit e3cb5f2

Browse files
committed
Class, typing subsection
1 parent d90d4d2 commit e3cb5f2

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,9 +1068,10 @@ from dataclasses import make_dataclass
10681068

10691069
#### Rest of type annotations (CPython interpreter ignores them all):
10701070
```python
1071+
import typing as tp, collections.abc as abc
1072+
<var_name>: list/set/abc.Iterable/abc.Sequence/tp.Optional[<type>] [= <obj>]
1073+
<var_name>: dict/tuple/tp.Union[<type>, ...] [= <obj>]
10711074
def func(<arg_name>: <type> [= <obj>]) -> <type>: ...
1072-
<var_name>: typing.List/Set/Iterable/Sequence/Optional[<type>]
1073-
<var_name>: typing.Dict/Tuple/Union[<type>, ...]
10741075
```
10751076

10761077
### Slots

index.html

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454

5555
<body>
5656
<header>
57-
<aside>April 13, 2023</aside>
57+
<aside>May 26, 2023</aside>
5858
<a href="https://gto76.github.io" rel="author">Jure Šorn</a>
5959
</header>
6060

@@ -903,9 +903,10 @@
903903
&lt;class&gt; = make_dataclass(<span class="hljs-string">'&lt;class_name&gt;'</span>, &lt;coll_of_tuples&gt;)
904904
&lt;tuple&gt; = (<span class="hljs-string">'&lt;attr_name&gt;'</span>, &lt;type&gt; [, &lt;default_value&gt;])</code></pre></div>
905905

906-
<div><h4 id="restoftypeannotationscpythoninterpreterignoresthemall">Rest of type annotations (CPython interpreter ignores them all):</h4><pre><code class="python language-python hljs"><span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">func</span><span class="hljs-params">(&lt;arg_name&gt;: &lt;type&gt; [= &lt;obj&gt;])</span> -&gt; &lt;type&gt;:</span> ...
907-
&lt;var_name&gt;: typing.List/Set/Iterable/Sequence/Optional[&lt;type&gt;]
908-
&lt;var_name&gt;: typing.Dict/Tuple/Union[&lt;type&gt;, ...]
906+
<div><h4 id="restoftypeannotationscpythoninterpreterignoresthemall">Rest of type annotations (CPython interpreter ignores them all):</h4><pre><code class="python language-python hljs"><span class="hljs-keyword">import</span> typing <span class="hljs-keyword">as</span> tp, collections.abc <span class="hljs-keyword">as</span> abc
907+
&lt;var_name&gt;: list/set/abc.Iterable/abc.Sequence/tp.Optional[&lt;type&gt;] [= &lt;obj&gt;]
908+
&lt;var_name&gt;: dict/tuple/tp.Union[&lt;type&gt;, ...] [= &lt;obj&gt;]
909+
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">func</span><span class="hljs-params">(&lt;arg_name&gt;: &lt;type&gt; [= &lt;obj&gt;])</span> -&gt; &lt;type&gt;:</span> ...
909910
</code></pre></div>
910911

911912
<div><h3 id="slots">Slots</h3><p><strong>Mechanism that restricts objects to attributes listed in 'slots' and significantly reduces their memory footprint.</strong></p><pre><code class="python language-python hljs"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">MyClassWithSlots</span>:</span>
@@ -2935,7 +2936,7 @@ <h3 id="format-2">Format</h3><div><h4 id="forstandardtypesizesandmanualalignment
29352936

29362937

29372938
<footer>
2938-
<aside>April 13, 2023</aside>
2939+
<aside>May 26, 2023</aside>
29392940
<a href="https://gto76.github.io" rel="author">Jure Šorn</a>
29402941
</footer>
29412942

0 commit comments

Comments
 (0)