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

Skip to content

Commit f7f20bb

Browse files
committed
Dictionary, Set, Mview
1 parent 7bacc33 commit f7f20bb

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ Dictionary
7777
```python
7878
value = <dict>.get(key, default=None) # Returns default if key is missing.
7979
value = <dict>.setdefault(key, default=None) # Returns and writes default if key is missing.
80-
<dict> = collections.defaultdict(<type>) # Creates a dict with default value of type.
81-
<dict> = collections.defaultdict(lambda: 1) # Creates a dict with default value 1.
80+
<dict> = collections.defaultdict(<type>) # Returns a dict with default value of type.
81+
<dict> = collections.defaultdict(lambda: 1) # Returns a dict with default value 1.
8282
```
8383

8484
```python
@@ -109,7 +109,7 @@ Counter({'blue': 3, 'red': 2, 'yellow': 1})
109109
Set
110110
---
111111
```python
112-
<set> = set() # {} returns a dictionary.
112+
<set> = set() # `{}` returns a dictionary.
113113
```
114114

115115
```python
@@ -2045,7 +2045,7 @@ Memory View
20452045

20462046
### Decode
20472047
```python
2048-
<bytes> = bytes(<mview>) # Creates a new bytes object.
2048+
<bytes> = bytes(<mview>) # Returns a new bytes object.
20492049
<bytes> = <bytes>.join(<coll_of_mviews>) # Joins mviews using bytes object as sep.
20502050
<array> = array('<typecode>', <mview>) # Treats mview as a sequence of numbers.
20512051
<file>.write(<mview>) # Writes mview to the binary file.

index.html

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

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

@@ -137,8 +137,8 @@
137137

138138
<pre><code class="python language-python hljs">value = &lt;dict&gt;.get(key, default=<span class="hljs-keyword">None</span>) <span class="hljs-comment"># Returns default if key is missing.</span>
139139
value = &lt;dict&gt;.setdefault(key, default=<span class="hljs-keyword">None</span>) <span class="hljs-comment"># Returns and writes default if key is missing.</span>
140-
&lt;dict&gt; = collections.defaultdict(&lt;type&gt;) <span class="hljs-comment"># Creates a dict with default value of type.</span>
141-
&lt;dict&gt; = collections.defaultdict(<span class="hljs-keyword">lambda</span>: <span class="hljs-number">1</span>) <span class="hljs-comment"># Creates a dict with default value 1.</span>
140+
&lt;dict&gt; = collections.defaultdict(&lt;type&gt;) <span class="hljs-comment"># Returns a dict with default value of type.</span>
141+
&lt;dict&gt; = collections.defaultdict(<span class="hljs-keyword">lambda</span>: <span class="hljs-number">1</span>) <span class="hljs-comment"># Returns a dict with default value 1.</span>
142142
</code></pre>
143143
<pre><code class="python language-python hljs">&lt;dict&gt; = dict(&lt;collection&gt;) <span class="hljs-comment"># Creates a dict from coll. of key-value pairs.</span>
144144
&lt;dict&gt; = dict(zip(keys, values)) <span class="hljs-comment"># Creates a dict from two collections.</span>
@@ -158,7 +158,7 @@
158158
(<span class="hljs-string">'blue'</span>, <span class="hljs-number">3</span>)
159159
</code></pre></div>
160160

161-
<div><h2 id="set"><a href="#set" name="set">#</a>Set</h2><pre><code class="python language-python hljs">&lt;set&gt; = set() <span class="hljs-comment"># {} returns a dictionary.</span>
161+
<div><h2 id="set"><a href="#set" name="set">#</a>Set</h2><pre><code class="python language-python hljs">&lt;set&gt; = set() <span class="hljs-comment"># `{}` returns a dictionary.</span>
162162
</code></pre></div>
163163

164164
<pre><code class="python language-python hljs">&lt;set&gt;.add(&lt;el&gt;) <span class="hljs-comment"># Or: &lt;set&gt; |= {&lt;el&gt;}</span>
@@ -1700,7 +1700,7 @@ <h3 id="format-2">Format</h3><div><h4 id="forstandardtypesizesandmanualalignment
17001700
</code></pre></div>
17011701

17021702

1703-
<div><h3 id="decode-2">Decode</h3><pre><code class="python language-python hljs">&lt;bytes&gt; = bytes(&lt;mview&gt;) <span class="hljs-comment"># Creates a new bytes object.</span>
1703+
<div><h3 id="decode-2">Decode</h3><pre><code class="python language-python hljs">&lt;bytes&gt; = bytes(&lt;mview&gt;) <span class="hljs-comment"># Returns a new bytes object.</span>
17041704
&lt;bytes&gt; = &lt;bytes&gt;.join(&lt;coll_of_mviews&gt;) <span class="hljs-comment"># Joins mviews using bytes object as sep.</span>
17051705
&lt;array&gt; = array(<span class="hljs-string">'&lt;typecode&gt;'</span>, &lt;mview&gt;) <span class="hljs-comment"># Treats mview as a sequence of numbers.</span>
17061706
&lt;file&gt;.write(&lt;mview&gt;) <span class="hljs-comment"># Writes mview to the binary file.</span>
@@ -2905,7 +2905,7 @@ <h3 id="format-2">Format</h3><div><h4 id="forstandardtypesizesandmanualalignment
29052905

29062906

29072907
<footer>
2908-
<aside>July 25, 2022</aside>
2908+
<aside>July 26, 2022</aside>
29092909
<a href="https://gto76.github.io" rel="author">Jure Šorn</a>
29102910
</footer>
29112911

0 commit comments

Comments
 (0)