Skip to content

Instantly share code, notes, and snippets.

@cacapon
Last active February 23, 2024 01:26
Show Gist options
  • Save cacapon/a4d84e85796b621c11067571cecc6e5e to your computer and use it in GitHub Desktop.
Save cacapon/a4d84e85796b621c11067571cecc6e5e to your computer and use it in GitHub Desktop.
デコレータの実装検証
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")
@cacapon
Copy link
Author

cacapon commented Feb 23, 2024

出力例

> $ python Commands/decorator.py
前処理
hello cacpaon
後処理

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment