Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

decorators in python

def deco(function):
    def wrap(num):
        if num % 2 == 0:
            print(num,"is even ")
        else:
            print(num,"is odd")
        function(num)
    return wrap
    
@deco
def display(num):
    return num
display(9)   # pass any number to check whether number is even or odd
Source by www.interviewbit.com #
 
PREVIOUS NEXT
Tagged: #decorators #python
ADD COMMENT
Topic
Name
1+5 =