change to decorator pattern
<p>I'm learning decorators and here I'm trying to change the below to decorator pattern.</p>

<pre><code>def invert(x):
    return 1/x

print invert(5)
</code></pre>

<p>can be changed using decorators.</p>

<pre><code>def safe(fun, *args):
    if args[0]!=0:
        return fun(*args)
    else:
        "Division by 0"

def invert(x):
    return 1/x

print safe(invert, 5) 
</code></pre>

<p>Using @wapper syntax,</p>

<pre><code>def safe(fun, *args):
    if args[0]!=0:
        return fun(*args)
    else:
        "Division by 0"
@safe
def invert(x):
    return 1/x

print invert(5)
</code></pre>

<p>The above code gives error <code>IndexError: tuple index out of range</code>. I'm trying to understand what makes it wrong and how to correct it.</p>
