The work-around is to use BeautifulSoup.new_string():
>>> comment = soup.new_string('42', Comment) >>> soup.find('div').insert_after(comment)
but this is rather counter-intuitive; I still feel NavigableString.__new__ could handle this implementation detail for us; Tag.__init__ does this already.
The work-around is to use BeautifulSoup. new_string( ):
>>> comment = soup.new_ string( '42', Comment) 'div'). insert_ after(comment)
>>> soup.find(
but this is rather counter-intuitive; I still feel NavigableString .__new_ _ could handle this implementation detail for us; Tag.__init__ does this already.