How to paste python code on wordpress?

Dan Lowe dan at tangledhelix.com
Tue Nov 22 03:10:56 CET 2005


On Nov 21, 2005, at 8:17 PM, could ildg wrote:

> Wordpress.com blog will eat up the spaces before a line,
> just as it will trim every line of my article. So I can't paste  
> python code indentedly.
> Does any one use wordpress blog here?
> Please tell me how to leave the sapces as they are when publishing  
> ariticles on the blog,

You can enclose the code in a PRE block, like this:

<pre>
def foobar():
     print "abc"
     if x == 3:
         print "def"
     print "ghi"
</pre>

If you don't care for how it renders in a browser, hack your CSS to  
make PRE render in a way you like.

  -dan

-- 
Well sure the government lies, and the press lies, but in a democracy
they aren't the same lies.            -Alexis A. Gilliland





More information about the Python-list mailing list