Program inefficiency?

George Sakkis george.sakkis at
Sun Sep 30 00:53:07 CEST 2007

On Sep 29, 2:32 pm, hall.j... at wrote:

> It think he's saying it should look like this:
> (line noise snipped)

Or you can let BeautifulSoup do the dirty job for you and forget all
this ugliness:

from BeautifulSoup import BeautifulSoup

soup = BeautifulSoup(text)
for a in soup.findAll('a'):
    for attr in 'href','name':
        val = a.get(attr)
        if val:
            a[attr] = val.replace(' ','_')
print soup


More information about the Python-list mailing list