|
|
@ -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"><frozenset> = frozenset(<collection>) |
|
|
|
</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"><tuple> = () |
|
|
|
<tuple> = (<el>, ) |
|
|
|
<tuple> = (<el_1>, <el_2>, ...) |
|
|
|
</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">>>> </span><span class="hljs-keyword">from</span> collections <span class="hljs-keyword">import</span> namedtuple |
|
|
|
<span class="hljs-meta">>>> </span>Point = namedtuple(<span class="hljs-string">'Point'</span>, <span class="hljs-string">'x y'</span>) |
|
|
|
<span class="hljs-meta">>>> </span>p = Point(<span class="hljs-number">1</span>, y=<span class="hljs-number">2</span>) |
|
|
|