How to paste python code on wordpress?

Iain King iainking at gmail.com
Tue Nov 22 10:52:40 CET 2005


Dan Lowe wrote:
> On Nov 22, 2005, at 12:30 AM, could ildg wrote:
>
> > Thank you~
> > It works!
> > but how can paste "<" and ">", please?
> > these 2 symbols will also confuse wordpress and I can't publish
> > what I want.
>
> Replace < with &lt;
>
> Replace > with &gt;
>
> (where those abbreviations stand for "less than" and "greater than")
>
> Before: if x < 5:
>
> After: if x &lt; 5:
>
> Another common character in code that you "should" do similarly is
> the double quote ("). For that, use &quot;
>
> Before: if x == "foo":
>
> After: if x == &quot;foo&quot;:
>
>   -dan
>
> --
> Any society that needs disclaimers has too many lawyers.  -Erik Pepke

You don't *need* to replace with &quot;
However, you will need to replace any ampersands with &amp; ( <, >, and
& are characters with intrinsic qualities in html).  You need to
replace & before you replace anything else: if you do it after
repalcing < and > you'll catch your &lt; and &gt;, ending up with
&amp;lt; and &amp;gt; which is not what you want.

Iain




More information about the Python-list mailing list