title: Python Beautiful soup insert comment in html
body: <p>I am trying to insert a comment in html using beautiful soup, I want to insert it before head closure, I am trying something like this</p>
  
  <pre><code>soup.head.insert(-1,"&lt;!-- #mycomment --&gt;")
  </code></pre>
  
  <p>It's inserting before <code>&lt;/head&gt;</code> but the value gets entity encoded <code>&amp;lt;!-- #mycomment --&amp;gt;</code>. Beautiful Soup documentation <a href="http://www.crummy.com/software/BeautifulSoup/bs4/doc/#insert" rel="nofollow">speaks about inserting</a> a tag but how should I insert a comment as it is.</p>