[reportlab-users] Re: usersGuide Platypus including '<' in text

Christoph Zwerschke cito at online.de
Sun Oct 29 18:08:23 EST 2006


Paulino wrote:
> You can use the re module to replace each character for it's escape 
> sequence in your paragraphs:
> 
> >>> string = 'smtih & smith'
> >>> import re
>  >>> re.sub('&', '&amp;', string)

Simpler: string.replace('&', '&amp;')

Or even simpler:

 >>> string = 'smith & wesson'
 >>> from xml.sax.saxutils import escape
 >>> escape(string)
'smith &amp; wesson'

-- Christoph


More information about the reportlab-users mailing list