Browse Source

Reverted repr() use cases

main
Jure Šorn 1 day ago
parent
commit
234cb5610b
2 changed files with 8 additions and 6 deletions
  1. 7
      index.html
  2. 7
      parse.js

7
index.html

@ -844,10 +844,11 @@ csv.writer(<file>).writerow([<obj>])
<span class="hljs-keyword">raise</span> Exception(&lt;obj&gt;)
</code></pre></div>
<div><h4 id="expressionsthatcallthereprmethod">Expressions that call the repr() method:</h4><pre><code class="python language-python hljs">print/str/repr([&lt;obj&gt;, ...])
print/str/repr({&lt;obj&gt;: &lt;obj&gt;, ...})
Z = make_dataclass(<span class="hljs-string">'Z'</span>, [<span class="hljs-string">'a'</span>]); print/str/repr(Z(&lt;obj&gt;))
<div><h4 id="expressionsthatcallthereprmethod">Expressions that call the repr() method:</h4><pre><code class="python language-python hljs">print/str/repr([&lt;obj&gt;])
print/str/repr({&lt;obj&gt;: &lt;obj&gt;})
<span class="hljs-string">f'<span class="hljs-subst">{&lt;obj&gt;!r}</span>'</span>
Z = make_dataclass(<span class="hljs-string">'Z'</span>, [<span class="hljs-string">'a'</span>]); print/str/repr(Z(&lt;obj&gt;))
<span class="hljs-meta">&gt;&gt;&gt; </span>&lt;obj&gt;
</code></pre></div>
<div><h3 id="inheritance">Inheritance</h3><pre><code class="python language-python hljs"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Person</span>:</span>

7
parse.js

@ -80,10 +80,11 @@ const PARAMETRIZED_DECORATOR =
' <span class="hljs-keyword">return</span> x + y\n';
const REPR_USE_CASES =
'print/str/repr([&lt;obj&gt;, ...])\n' +
'print/str/repr({&lt;obj&gt;: &lt;obj&gt;, ...})\n' +
'print/str/repr([&lt;obj&gt;])\n' +
'print/str/repr({&lt;obj&gt;: &lt;obj&gt;})\n' +
'<span class="hljs-string">f\'<span class="hljs-subst">{&lt;obj&gt;!r}</span>\'</span>\n' +
'Z = make_dataclass(<span class="hljs-string">\'Z\'</span>, [<span class="hljs-string">\'a\'</span>]); print/str/repr(Z(&lt;obj&gt;))\n' +
'<span class="hljs-string">f\'<span class="hljs-subst">{&lt;obj&gt;!r}</span>\'</span>\n';
'<span class="hljs-meta">&gt;&gt;&gt; </span>&lt;obj&gt;\n';
const CONSTRUCTOR_OVERLOADING =
'<span class="hljs-class"><span class="hljs-keyword">class</span> &lt;<span class="hljs-title">name</span>&gt;:</span>\n' +

Loading…
Cancel
Save