Python - Get original function arguments in decorator

Solution 1:

The decorator login_required is passed the function (hello in this case).

So what you want to do is:

def login_required(f):
    # This function is what we "replace" hello with
    def wrapper(*args, **kw):
        args[0].client_session['test'] = True
        logged_in = 0
        if logged_in:
            return f(*args, **kw)  # Call hello
        else:
            return redirect(url_for('login'))
    return wrapper

Solution 2:

kwargs is a dictionary containing argument as keys and values as values.

So all you need to do is check: some_var = kw['my_property']