2
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

メソッド終了時に「FIN メソッド名」と表示するデコレータ

Last updated at Posted at 2020-02-20
python
def print_fin(func):
    def wrapper(*args, **kwargs):
        output = func(*args, **kwargs)
        print(f'FIN {func.__name__}')
        return output
    return wrapper

使い方:

python
@print_fin
def greet():
    print('Hello!')

greet()
結果
Hello!
FIN greet

参考:Pythonのデコレータについて - Qiita

2
4
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
2
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?