LoginSignup
0
0

More than 1 year has passed since last update.

デコレーター

Posted at
def my_decorator(func):
    def wrapper():
        print("デコレーターの前処理")
        func()
        print("デコレーターの後処理")
    return wrapper

@my_decorator
def my_function():
    print("Hello, World!")


my_function()
デコレーターの前処理
Hello, World!
デコレーターの後処理

my_functionのデコレーターが呼び出される
my_decoretorの引数としてmy_functionが渡される。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0