import inspect


def _guess_var_name(var):
    """
    Guesses the argument name, according to the variable name sent to it, if
    unable to guess, returns 'arg'. See https://stackoverflow.com/a/2749881

    Args:
        var (object): the variable to figure the argument name

    Returns:
        str: the argument name, according to the variable name sent to it, if
            unable to guess, returns 'arg'.
    """
    for stack in range(2, len(inspect.stack())):
        lcls = inspect.stack()[stack][0].f_locals
        for name in lcls:
            if id(var) == id(lcls[name]):
                return name
    return 'arg'