diff --git a/compat.html b/compat.html index 1187dd9be5a2696b458b8e070b111c3a35c1e7c6_Y29tcGF0Lmh0bWw=..75e016538c7a1dfb50c2efee39dbd75f8635a96f_Y29tcGF0Lmh0bWw= 100644 --- a/compat.html +++ b/compat.html @@ -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("filename", "w").write("stuff") -</pre> -<p>The proper fix is:</p> -<pre class="literal-block"> -f = open("filename", "w") -f.write("stuff") -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("filename", "w") as f: - f.write("stuff") -</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">"filename"</span><span class="p">,</span> <span class="s">"w"</span><span class="p">)</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s">"stuff"</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">"filename"</span><span class="p">,</span> <span class="s">"w"</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">"stuff"</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">"filename"</span><span class="p">,</span> <span class="s">"w"</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">"stuff"</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> diff --git a/source/compat.txt b/source/compat.txt index 1187dd9be5a2696b458b8e070b111c3a35c1e7c6_c291cmNlL2NvbXBhdC50eHQ=..75e016538c7a1dfb50c2efee39dbd75f8635a96f_c291cmNlL2NvbXBhdC50eHQ= 100644 --- a/source/compat.txt +++ b/source/compat.txt @@ -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