Skip to content
Snippets Groups Projects
Commit 75e01653 authored by Maciej Fijalkowski's avatar Maciej Fijalkowski
Browse files

use syntax highlightning

parent 1187dd9b
No related branches found
No related tags found
No related merge requests found
......@@ -75,21 +75,12 @@
<ul>
<li><p class="first">PyPy does not support refcounting semantics. The code below
won't fill the file immediately, but only after a certain period
of time, when the GC will collect:</p>
<pre class="literal-block">
open(&quot;filename&quot;, &quot;w&quot;).write(&quot;stuff&quot;)
</pre>
<p>The proper fix is:</p>
<pre class="literal-block">
f = open(&quot;filename&quot;, &quot;w&quot;)
f.write(&quot;stuff&quot;)
f.close()
</pre>
<p>or using the <tt class="docutils literal"><span class="pre">with</span></tt> keyword:</p>
<pre class="literal-block">
with open(&quot;filename&quot;, &quot;w&quot;) as f:
f.write(&quot;stuff&quot;)
</pre>
of time, when the GC will collect</p>
<div class="syntax python"><pre><span class="nb">open</span><span class="p">(</span><span class="s">&quot;filename&quot;</span><span class="p">,</span> <span class="s">&quot;w&quot;</span><span class="p">)</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s">&quot;stuff&quot;</span><span class="p">)</span><br/></pre></div>
<p>The proper fix is</p>
<div class="syntax python"><pre><span class="n">f</span> <span class="o">=</span> <span class="nb">open</span><span class="p">(</span><span class="s">&quot;filename&quot;</span><span class="p">,</span> <span class="s">&quot;w&quot;</span><span class="p">)</span><br/><span class="n">f</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s">&quot;stuff&quot;</span><span class="p">)</span><br/><span class="n">f</span><span class="o">.</span><span class="n">close</span><span class="p">()</span><br/></pre></div>
<p>or using the <tt class="docutils literal"><span class="pre">with</span></tt> keyword</p>
<div class="syntax python"><pre><span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="s">&quot;filename&quot;</span><span class="p">,</span> <span class="s">&quot;w&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span><br/> <span class="n">f</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s">&quot;stuff&quot;</span><span class="p">)</span><br/></pre></div>
</li>
<li><p class="first">We don't support certain attributes that were decided to be
implementation-dependent. For example, <tt class="docutils literal"><span class="pre">gc.get_referrers</span></tt> does not exist.
......@@ -99,11 +90,8 @@
</li>
<li><p class="first">You can't attach a <tt class="docutils literal"><span class="pre">__del__</span></tt> method to a class after its creation.</p>
</li>
<li><p class="first">You can't store non-string keys in type objects. Example:</p>
<pre class="literal-block">
class A(object):
locals()[42] = 3
</pre>
<li><p class="first">You can't store non-string keys in type objects. Example</p>
<div class="syntax python"><pre><span class="k">class</span> <span class="nc">A</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span><br/> <span class="nb">locals</span><span class="p">()[</span><span class="mi">42</span><span class="p">]</span> <span class="o">=</span> <span class="mi">3</span><br/></pre></div>
<p>won't work.</p>
</li>
</ul>
......
......@@ -39,7 +39,9 @@
* PyPy does not support refcounting semantics. The code below
won't fill the file immediately, but only after a certain period
of time, when the GC will collect::
of time, when the GC will collect
.. syntax:: python
open("filename", "w").write("stuff")
......@@ -43,9 +45,11 @@
open("filename", "w").write("stuff")
The proper fix is::
The proper fix is
.. syntax:: python
f = open("filename", "w")
f.write("stuff")
f.close()
......@@ -47,9 +51,11 @@
f = open("filename", "w")
f.write("stuff")
f.close()
or using the ``with`` keyword::
or using the ``with`` keyword
.. syntax:: python
with open("filename", "w") as f:
f.write("stuff")
......@@ -62,7 +68,9 @@
* You can't attach a ``__del__`` method to a class after its creation.
* You can't store non-string keys in type objects. Example::
* You can't store non-string keys in type objects. Example
.. syntax:: python
class A(object):
locals()[42] = 3
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment