Browse Source

Tuple

pull/36/head
Jure Šorn 5 years ago
parent
commit
751770ae20
2 changed files with 8 additions and 8 deletions
  1. 8
      README.md
  2. 8
      index.html

8
README.md

@ -128,8 +128,8 @@ Set
```
### Frozen Set
* **Frozen set is immutable and hashable set.**
* **It can be used as a key in a dictionary or as an element in a set.**
* **Is immutable and hashable.**
* **That means it can be used as a key in a dictionary or as an element in a set.**
```python
<frozenset> = frozenset(<collection>)
```
@ -137,7 +137,7 @@ Set
Tuple
-----
**Tuple is immutable and hashable list.**
**Tuple is an immutable and hashable list.**
```python
<tuple> = ()
<tuple> = (<el>, )
@ -145,7 +145,7 @@ Tuple
```
### Named Tuple
**Named tuple is tuple's subclass with named elements.**
**Tuple's subclass with named elements.**
```python
>>> from collections import namedtuple

8
index.html

@ -288,19 +288,19 @@ Counter({<span class="hljs-string">'blue'</span>: <span class="hljs-number">3</s
</code></pre>
<h3 id="frozenset">Frozen Set</h3>
<ul>
<li><strong>Frozen set is immutable and hashable set.</strong></li>
<li><strong>It can be used as a key in a dictionary or as an element in a set.</strong></li>
<li><strong>Is immutable and hashable.</strong></li>
<li><strong>That means it can be used as a key in a dictionary or as an element in a set.</strong></li>
</ul>
<pre><code class="python language-python hljs">&lt;frozenset&gt; = frozenset(&lt;collection&gt;)
</code></pre>
<h2 id="tuple"><a href="#tuple" name="tuple">#</a>Tuple</h2>
<p><strong>Tuple is immutable and hashable list.</strong></p>
<p><strong>Tuple is an immutable and hashable list.</strong></p>
<pre><code class="python language-python hljs">&lt;tuple&gt; = ()
&lt;tuple&gt; = (&lt;el&gt;, )
&lt;tuple&gt; = (&lt;el_1&gt;, &lt;el_2&gt;, ...)
</code></pre>
<h3 id="namedtuple">Named Tuple</h3>
<p><strong>Named tuple is tuple's subclass with named elements.</strong></p>
<p><strong>Tuple's subclass with named elements.</strong></p>
<pre><code class="python language-python hljs"><span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> collections <span class="hljs-keyword">import</span> namedtuple
<span class="hljs-meta">&gt;&gt;&gt; </span>Point = namedtuple(<span class="hljs-string">'Point'</span>, <span class="hljs-string">'x y'</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>p = Point(<span class="hljs-number">1</span>, y=<span class="hljs-number">2</span>)

Loading…
Cancel
Save