human
Complete this python program:
def _dict_pprinter_factory(start, end, basetype=None):
assistant
#Here is the Python code you requested.

    """Factory that returns a pprint function used by the default pprint of
    dicts and dict proxies.
    """
    def inner(obj, p, cycle):
        typ = type(obj)
        if ((basetype is not None) and (typ is not basetype) and (typ.__repr__ != basetype.__repr__)):
            return p.text(typ.__repr__(obj))
        if cycle:
            return p.text('{...}')
        step = len(start)
        p.begin_group(step, start)
        keys = obj.keys()
        if (not (p.max_seq_length and (len(obj) >= p.max_seq_length))):
            try:
                keys = sorted(keys)
            except Exception:
                pass
        for (idx, key) in p._enumerate(keys):
            if idx:
                p.text(',')
                p.breakable()
            p.pretty(key)
            p.text(':    ')
            p.pretty(obj[key])
        p.end_group(step, end)
    return inner