def set(obj, path, value, create_missing=True, afilter=None):
cur = obj<EOL>traversed = []<EOL>def _presence_test_dict(obj, elem):<EOL><INDENT>return (elem[<NUM_LIT:0>] in obj)<EOL><DEDENT>def _create_missing_dict(obj, elem):<EOL><INDENT>obj[elem[<NUM_LIT:0>]] = elem[<NUM_LIT:1>]()<EOL><DEDENT>def _presence_test_list(obj, elem):<EOL><INDENT>return (int(str(elem[<NUM_LIT:0>])) < len(obj))<EOL><DEDENT>def _create_missing_list(obj, elem):<EOL><INDENT>idx = int(str(elem[<NUM_LIT:0>]))<EOL>while (len(obj)-<NUM_LIT:1>) < idx:<EOL><INDENT>obj.append(None)<EOL><DEDENT><DEDENT>def _accessor_dict(obj, elem):<EOL><INDENT>return obj[elem[<NUM_LIT:0>]]<EOL><DEDENT>def _accessor_list(obj, elem):<EOL><INDENT>return obj[int(str(elem[<NUM_LIT:0>]))]<EOL><DEDENT>def _assigner_dict(obj, elem, value):<EOL><INDENT>obj[elem[<NUM_LIT:0>]] = value<EOL><DEDENT>def _assigner_list(obj, elem, value):<EOL><INDENT>obj[int(str(elem[<NUM_LIT:0>]))] = value<EOL><DEDENT>elem = None<EOL>for elem in path:<EOL><INDENT>elem_value = elem[<NUM_LIT:0>]<EOL>elem_type = elem[<NUM_LIT:1>]<EOL>tester = None<EOL>creator = None<EOL>accessor = None<EOL>assigner = None<EOL>if issubclass(obj.__class__, (MutableMapping)):<EOL><INDENT>tester = _presence_test_dict<EOL>creator = _create_missing_dict<EOL>accessor = _accessor_dict<EOL>assigner = _assigner_dict<EOL><DEDENT>elif issubclass(obj.__class__, MutableSequence):<EOL><INDENT>if not str(elem_value).isdigit():<EOL><INDENT>raise TypeError("<STR_LIT>"<EOL>"<STR_LIT>".format(type(obj),<EOL>traversed<EOL>)<EOL>)<EOL><DEDENT>tester = _presence_test_list<EOL>creator = _create_missing_list<EOL>accessor = _accessor_list<EOL>assigner = _assigner_list<EOL><DEDENT>else:<EOL><INDENT>raise TypeError("<STR_LIT>"<EOL>"<STR_LIT>".format(obj, traversed))<EOL><DEDENT>if (not tester(obj, elem)) and (create_missing):<EOL><INDENT>creator(obj, elem)<EOL><DEDENT>elif (not tester(obj, elem)):<EOL><INDENT>raise dpath.exceptions.PathNotFound(<EOL>"<STR_LIT>".format(<EOL>elem,<EOL>traversed<EOL>)<EOL>)<EOL><DEDENT>traversed.append(elem_value)<EOL>if len(traversed) < len(path):<EOL><INDENT>obj = accessor(obj, elem)<EOL><DEDENT><DEDENT>if elem is None:<EOL><INDENT>return<EOL><DEDENT>if (afilter and afilter(accessor(obj, elem))) or (not afilter):<EOL><INDENT>assigner(obj, elem, value)<EOL><DEDENT>
Set the value of the given path in the object. Path
    must be a list of specific path elements, not a glob.
    You can use dpath.util.set for globs, but the paths must
    slready exist.

    If create_missing is True (the default behavior), then any
    missing path components in the dictionary are made silently.
    Otherwise, if False, an exception is thrown if path
    components are missing.