def parse ( el , typ ) : if not el : return typ ( ) txt = text ( el ) if not txt : return typ ( ) return typ ( txt )
python beautifulsoup 'nonetype' object is not callable
Parse a BeautifulSoup element as the given type .
def parse(el, typ):
    """
    Parse a ``BeautifulSoup`` element as the given type.
    """
    if not el:
        return typ()
    txt = text(el)
    if not txt:
        return typ()
    return typ(txt)