def has_class_but_no_id(tag): return tag.has_attr('class') and not tag.has_attr('id')
soup = BeautifulSoup('<b class="boldest">Extremely bold</b>', 'html.parser') tag = soup.b type(tag) # <class 'bs4.element.Tag'>