Decorator that displays "FIN method name" at the end of the method

python


def print_fin(func):
    def wrapper(*args, **kwargs):
        output = func(*args, **kwargs)
        print(f'FIN {func.__name__}')
        return output
    return wrapper

How to use:

python


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

greet()

result


Hello!
FIN greet

Reference: [About Python Decorator-Qiita](https://qiita.com/mtb_beta/items/d257519b018b8cd0cc2e#%E3%81%A4%E3%81%BE%E3%82%8A%E3%83%87% E3% 82% B3% E3% 83% AC% E3% 83% BC% E3% 82% BF% E3% 81% A7% E4% BD% 95% E3% 81% 8C% E3% 81% A7% E3% 81% 8D% E3% 82% 8B% E3% 81% AE% E3% 81% 8B)

Recommended Posts

Decorator that displays "FIN method name" at the end of the method
Python Basic Course (at the end of 15)
Find out the name of the method that called it from the method that is python
Send Gmail at the end of the process [Python]
Remove specific strings at the end of python
About the matter that softmax is not needed at the end of Torchvision model.
Get the class name where the method is defined in the decorator
I want to get the name of the function / method being executed
pandas Fetch the name of a column that contains a specific character
Embedding method DensMAP that reflects the density of distribution of high-dimensional data
A function that measures the processing time of a method in python
I investigated the X-means method that automatically estimates the number of clusters
Clean up the repository at the end of the year and delete DS.store
Try to react only the carbon at the end of the chain with SMARTS
Summarize the titles of Hottentori at the end and look at the present on the Web
python> print> Redirected only at the end of processing?> Run with -u
This and that of the inclusion notation.
Count / verify the number of method calls.
Shout Hello, Reiwa! At the beginning of Reiwa
Set the process name of the Python program
Automation of creation of working hours table created at the end of the month with Selenium
[Python] The movement of the decorator that can be understood this time ② The decorator that receives the argument
The story of IPv6 address that I want to keep at a minimum
Create a BOT that displays the number of infected people in the new corona
The story of the learning method that acquired LinuC Level 1 with only ping -t