|
|
@ -385,6 +385,7 @@ Point(x=<span class="hljs-number">1</span>, y=<span class="hljs-number">2</span> |
|
|
|
<pre><code class="python language-python hljs"><str> = <span class="hljs-string">f'<span class="hljs-subst">{<el_1>}</span>, <span class="hljs-subst">{<el_2>}</span>'</span> |
|
|
|
<str> = <span class="hljs-string">'{}, {}'</span>.format(<el_1>, <el_2>) |
|
|
|
</code></pre> |
|
|
|
<h3 id="attributes">Attributes</h3> |
|
|
|
<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>Person = namedtuple(<span class="hljs-string">'Person'</span>, <span class="hljs-string">'name height'</span>) |
|
|
|
<span class="hljs-meta">>>> </span>person = Person(<span class="hljs-string">'Jean-Luc'</span>, <span class="hljs-number">187</span>) |
|
|
@ -395,9 +396,10 @@ Point(x=<span class="hljs-number">1</span>, y=<span class="hljs-number">2</span> |
|
|
|
</code></pre> |
|
|
|
<h3 id="generaloptions">General Options</h3> |
|
|
|
<pre><code class="python language-python hljs">{<el>:<<span class="hljs-number">10</span>} <span class="hljs-comment"># '<el> '</span> |
|
|
|
{<el>:><span class="hljs-number">10</span>} <span class="hljs-comment"># ' <el>'</span> |
|
|
|
{<el>:^<span class="hljs-number">10</span>} <span class="hljs-comment"># ' <el> '</span> |
|
|
|
{<el>:.><span class="hljs-number">10</span>} <span class="hljs-comment"># '......<el>'</span> |
|
|
|
{<el>:><span class="hljs-number">10</span>} <span class="hljs-comment"># ' <el>'</span> |
|
|
|
</code></pre> |
|
|
|
<pre><code class="python language-python hljs">{<el>:.<<span class="hljs-number">10</span>} <span class="hljs-comment"># '<el>......'</span> |
|
|
|
{<el>:><span class="hljs-number">0</span>} <span class="hljs-comment"># '<el>'</span> |
|
|
|
</code></pre> |
|
|
|
<h3 id="stringoptions">String Options</h3> |
|
|
@ -1218,7 +1220,7 @@ lock.release() |
|
|
|
<dict> = locals() <span class="hljs-comment"># Dict of local variables. Also vars().</span> |
|
|
|
<dict> = globals() <span class="hljs-comment"># Dict of global variables.</span> |
|
|
|
</code></pre> |
|
|
|
<h3 id="attributes">Attributes</h3> |
|
|
|
<h3 id="attributes-1">Attributes</h3> |
|
|
|
<pre><code class="python language-python hljs"><dict> = vars(<object>) |
|
|
|
<bool> = hasattr(<object>, <span class="hljs-string">'<attr_name>'</span>) |
|
|
|
value = getattr(<object>, <span class="hljs-string">'<attr_name>'</span>) |
|
|
|