pretty prints a (list tuple,  dict etc) object

    :useful:
        - when we want to avoid importing pprint if we have already imported json
        - when we want to pprint to file without breaking json compatibility

def pp_obj(obj, out_path=None, indent=4, sort_keys=False, ensure_ascii=False, default=None):
    """
    pretty prints a (list tuple,  dict etc) object

    :useful:
        - when we want to avoid importing pprint if we have already imported json
        - when we want to pprint to file without breaking json compatibility
    """
    rt = anyjson.dumps(obj, sort_keys=sort_keys, indent=indent, ensure_ascii=ensure_ascii,
                       separators=(',', ': '), default=default, namedtuple_as_object=False)
    # unicode_available
    if out_path is None:
        return rt
    else:
        with open(out_path, 'w') as out:
            out.write(rt)