Here's another interesting BeautifulSoup snippet that I've just successfully used:
Code:
# convert all html text to block text format
for tag in soup.findAll('p'):
if tag.has_attr('style') and 'text-align: center' not in tag['style'].lower():
del tag['style']
tag['class'] = 'BlockText'
The above four lines of code will delete all 'style' attributes in p tags and then add the BlockText class - centered text will not be affected.