I\'m trying to learn Decorators . I understood the concept of it and now trying to implement it.
Here is the code that I\'ve written The code is se
Your decorator should look like this:
def wrapper(func):
def inner(x, y): # inner function needs parameters
if issubclass(type(x), int): # maybe you looked for isinstance?
return func(x, y) # call the wrapped function
else:
return 'invalid values'
return inner # return the inner function (don't call it)
Some points to note:
issubclass
expects a class as first argument (you could replace it with a simple try/except TypeError).You can find a good explanation of decorators here.