Python:Decorator parameters passing questions
<p>I wrote a python decorator as follow:</p>

<pre><code>class Cache(object):
    def __init__(self, func):
        self.func = func
        try:
            from settings import REDIS_HOST
            self.redis = redis.Redis(REDIS_HOST)
        except:
            self.redis = redis.Redis('localhost')

    def __call__(self, *args, **kwargs):
        print args
        gen_key = kwargs.get('key', None)
        if gen_key:
            value = self.redis.get(gen_key)
            if value:
                return value
            else:
                value = self.func(*args, **kwargs)
                self.redis.setex(value, gen_key, 1800)
                return value
        else:
            raise UnsuportedArgsError
</code></pre>

<p>and using it as follow:</p>

<pre><code>@Cache
def on_schedule_handle(data, bot, key):
...

def high_handle(test):
...
    on_schedule_handle(data, bot, key)
...
</code></pre>

<p>A strange thing occurs:
if i invoke on_schedule_handle directly , the args in <code>__call__</code> is "data, bot, key", it's ok!
but if i invoke high_handle which innerly invokes on_schedule_handle, the args in <code>__call__</code> is "test"!
I have no idea about it.
anyone can explain this? THX...</p>
