Gets data from query_func, optionally saving that data to a file; or loads data from a file.

def get_data(query_func, load_data=False, save_data=False):
    """Gets data from query_func, optionally saving that data to a file; or loads data from a file."""
    if hasattr(query_func, '__name__'):
        func_name = query_func.__name__
    elif hasattr(query_func, 'func'):
        func_name = query_func.func.__name__

    pickle_file = '{}.pickle'.format(func_name)

    if load_data:
        data = load_object(pickle_file)
    else:
        data = query_func()
        if save_data:
            save_object(pickle_file, data)
    return data