def findElementsWithAttributeShallow(parent, attribute):
    """
    Return an iterable of the elements which are direct children of C{parent}
    and which have the C{attribute} attribute.
    """
    return findNodesShallow(parent,
        lambda n: getattr(n, 'tagName', None) is not None and
            n.hasAttribute(attribute))

    Return an iterable of the elements which are direct children of C{parent}
    and which have the C{attribute} attribute.
    
stackoverflow/venv/lib/python3.6/site-packages/twisted/web/domhelpers.py