def encode_entities(string):
    if isinstance(string, basestring):
        string = RE_AMPERSAND.sub("&amp;", string)
        string = string.replace("<", "&lt;")
        string = string.replace(">", "&gt;")
        string = string.replace('"', "&quot;")
        string = string.replace("'", "&#39;")
    return string
Encodes HTML entities in the given string ("<" => "&lt;").
dataset/ETHPy150Open clips/pattern/pattern/server/__init__.py/encode_entities