title: BeautifulSoup: get tag name of element itself, not its children
body: <p>I have the below (simplified) code, which uses the following source:</p>
  
  <pre><code>&lt;html&gt;
      &lt;p&gt;line 1&lt;/p&gt;
      &lt;div&gt;
          &lt;a&gt;line 2&lt;/a&gt;
      &lt;/div&gt;
  &lt;/html&gt;
  
  soup = BeautifulSoup('&lt;html&gt;&lt;p&gt;line 1&lt;/p&gt;&lt;div&gt;&lt;a&gt;line 2&lt;/a&gt;&lt;/div&gt;&lt;/html&gt;')
  ele = soup.find('p').nextSibling
  somehow_print_tag_of_ele_here
  </code></pre>
  
  <p>I want to get the tag of ele, in this case "div". However, I only seem to be able to get the tag of its children. Am I missing something simple? I thought that I could do ele.tag.name, but that is an exception since tag is None.</p>
  
  <pre><code>#Below correctly prints the div element "&lt;div&gt;&lt;a&gt;line 2&lt;/a&gt;&lt;/div&gt;"
  print ele
  
  #Below prints "None". Printing tag.name is an exception since tag is None
  print ele.tag 
  
  #Below prints "a", the child of ele
  allTags = ele.findAll(True)
  for e in allTags:
      print e.name
  </code></pre>
  
  <p>At this point, I am considering doing something along the way of getting the parent of ele, then getting the tags of parent's children and, having counted how many upper siblings ele has, counting down to the correct child tag. That seems ridiculous.</p>