Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Message from discussion How do you htmlentities in Python

View parsed - Show only message text

Path: g2news1.google.com!postnews.google.com!q75g2000hsh.googlegroups.com!not-for-mail
From:  Adam Atlas <a...@atlas.st>
Newsgroups: comp.lang.python
Subject: Re: How do you htmlentities in Python
Date: Mon, 04 Jun 2007 07:03:12 -0700
Organization: http://groups.google.com
Lines: 9
Message-ID: <1180965792.757685.132580@q75g2000hsh.googlegroups.com>
References: <mailman.8674.1180963921.32031.python-list@python.org>
NNTP-Posting-Host: 67.87.243.202
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
X-Trace: posting.google.com 1180965793 4594 127.0.0.1 (4 Jun 2007 14:03:13 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Mon, 4 Jun 2007 14:03:13 +0000 (UTC)
In-Reply-To: <mailman.8674.1180963921.32031.python-list@python.org>
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/418.9 (KHTML, like Gecko) Safari/419.3,gzip(gfe),gzip(gfe)
Complaints-To: groups-abuse@google.com
Injection-Info: q75g2000hsh.googlegroups.com; posting-host=67.87.243.202;
   posting-account=G8uqwAwAAAClRZtdN3cZRvCNaOX1gZ2b

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)


Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google