title: Test if an attribute is present in a tag in BeautifulSoup
body: <p>I would like to get all the <code>&lt;script&gt;</code> tags in a document and then process each one based on the presence (or absence) of certain attributes.</p>
  
  <p>E.g., for each <code>&lt;script&gt;</code> tag, if the attribute <code>for</code> is present do something; else if the attribute <code>bar</code> is present do something else.</p>
  
  <p>Here is what I am doing currently:</p>
  
  <pre><code>outputDoc = BeautifulSoup(''.join(output))
  scriptTags = outputDoc.findAll('script', attrs = {'for' : True})
  </code></pre>
  
  <p>But this way I filter all the <code>&lt;script&gt;</code> tags with the <code>for</code> attribute... but I lost the other ones (those without the <code>for</code> attribute).</p>