+ 2
It seems that's how it should be:
def div(a, b):
print(a / b)
def smart_div(func):
def inner(a, b):
if a < b:
a, b = b, a
return func(a, b)
return inner
div = smart_div(div)
div(2, 4)
First mistake is a name of the function. It shouldn't contain spaces: smart_div.
2. an external function shoud return something: return inner.
3. inner function should take arguments.
4. a wrong call of a function: div = (2, 4)
It could be written in a decorator comprehension:
def smart_div(func):
def inner(a, b):
if a < b:
a, b = b, a
return func(a, b)
return inner
@smart_div
def div(a, b):
print(a / b)
div(2, 4)



