Last active
February 23, 2024 01:26
-
-
Save cacapon/a4d84e85796b621c11067571cecc6e5e to your computer and use it in GitHub Desktop.
デコレータの実装検証
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def decorator(func): | |
def wrap(*arg, **keyword): | |
print("前処理") | |
func(*arg,**keyword) | |
print("後処理") | |
return wrap | |
@decorator | |
def function(string:str): | |
print(f"hello {string}") | |
function("cacpaon") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
出力例
> $ python Commands/decorator.py 前処理 hello cacpaon 後処理