def delete(obj, glob, separator="<STR_LIT:/>", afilter=None):
deleted = <NUM_LIT:0><EOL>paths = []<EOL>globlist = __safe_path__(glob, separator)<EOL>for path in _inner_search(obj, globlist, separator):<EOL><INDENT>paths.append(path)<EOL><DEDENT>for path in paths:<EOL><INDENT>cur = obj<EOL>prev = None<EOL>for item in path:<EOL><INDENT>prev = cur<EOL>try:<EOL><INDENT>cur = cur[item[<NUM_LIT:0>]]<EOL><DEDENT>except AttributeError as e:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>if (not afilter) or (afilter and afilter(prev[item[<NUM_LIT:0>]])):<EOL><INDENT>prev.pop(item[<NUM_LIT:0>])<EOL><DEDENT>deleted += <NUM_LIT:1><EOL><DEDENT>if not deleted:<EOL><INDENT>raise dpath.exceptions.PathNotFound("<STR_LIT>".format(glob))<EOL><DEDENT>return deleted<EOL>
Given a path glob, delete all elements that match the glob.

Returns the number of deleted objects. Raises PathNotFound if no paths are
found to delete.