Demo entry 5879975

decorators

   

Submitted by anonymous on Aug 26, 2016 at 18:48
Language: Python. Code size: 390 Bytes.

def my_decorator(some_function):

    def wrapper():

        print("Something is happening before some_function() is called.")

        some_function()

        print("Something is happening after some_function() is called.")

    return wrapper


def just_some_function():
    print("Wheee!")


just_some_function = my_decorator(just_some_function)

just_some_function(

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).