Re: How do you htmlentities in Python

2007-06-06 Thread John J. Lee
"Thomas Jollans" <[EMAIL PROTECTED]> writes: > "Adam Atlas" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > As far as I know, there isn't a standard idiom to do this, but it's > > still a one-liner. Untested, but I think this should work: > > > > import re > > from htmlentitydef

Re: How do you htmlentities in Python

2007-06-05 Thread Cameron Laird
In article <[EMAIL PROTECTED]>, Matimus <[EMAIL PROTECTED]> wrote: >On Jun 4, 6:31 am, "js " <[EMAIL PROTECTED]> wrote: >> Hi list. >> >> If I'm not mistaken, in python, there's no standard library to convert >> html entities, like & or > into their applicable characters. >> >> htmlentitydefs prov

Re: How do you htmlentities in Python

2007-06-04 Thread js
Thanks you Matimus. That's exactly what I'm looking for! Easy, clean and customizable. I love python :) On 6/5/07, Matimus <[EMAIL PROTECTED]> wrote: > On Jun 4, 6:31 am, "js " <[EMAIL PROTECTED]> wrote: > > Hi list. > > > > If I'm not mistaken, in python, there's no standard library to convert >

Re: How do you htmlentities in Python

2007-06-04 Thread Matimus
On Jun 4, 6:31 am, "js " <[EMAIL PROTECTED]> wrote: > Hi list. > > If I'm not mistaken, in python, there's no standard library to convert > html entities, like & or > into their applicable characters. > > htmlentitydefs provides maps that helps this conversion, > but it's not a function so you have

Re: How do you htmlentities in Python

2007-06-04 Thread Cameron Laird
In article <[EMAIL PROTECTED]>, Adam Atlas <[EMAIL PROTECTED]> wrote: >As far as I know, there isn't a standard idiom to do this, but it's >still a one-liner. Untested, but I think this should work: > >import re >from htmlentitydefs import name2codepoint >def htmlentitydecode(s): >return re.su

Re: How do you htmlentities in Python

2007-06-04 Thread Thomas Jollans
"Adam Atlas" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > As far as I know, there isn't a standard idiom to do this, but it's > still a one-liner. Untested, but I think this should work: > > import re > from htmlentitydefs import name2codepoint > def htmlentitydecode(s): >retu

Re: How do you htmlentities in Python

2007-06-04 Thread Cameron Laird
In article <[EMAIL PROTECTED]>, Adam Atlas <[EMAIL PROTECTED]> wrote: >As far as I know, there isn't a standard idiom to do this, but it's >still a one-liner. Untested, but I think this should work: > >import re >from htmlentitydefs import name2codepoint >def htmlentitydecode(s): >return re.su

Re: How do you htmlentities in Python

2007-06-04 Thread Adam Atlas
As far as I know, there isn't a standard idiom to do this, but it's still a one-liner. Untested, but I think this should work: import re from htmlentitydefs import name2codepoint def htmlentitydecode(s): return re.sub('&(%s);' % '|'.join(name2codepoint), lambda m: name2codepoint[m.group(1)], s