Skip to content

Commit

Permalink
simplify python docstrings decorator example
Browse files Browse the repository at this point in the history
  • Loading branch information
copdips committed Nov 16, 2024
1 parent 171a6e9 commit 7ad19eb
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,22 +69,21 @@ by the param grid.
def my_decorator(func):
@functools.wraps(func)
def wrapper(*args, **kwargs):
print("Something is happening before the function is called.")
print("Before the function is called.")
result = func(*args, **kwargs)
print("Something is happening after the function is called.")
print("After the function is called.")
return result
return wrapper

@my_decorator
def say_hello():
"""This function says hello."""
print("Hello!")

say_hello()

"""output:
Something is happening before the function is called.
Before the function is called.
Hello!
Something is happening after the function is called.
After the function is called.
"""
```

0 comments on commit 7ad19eb

Please sign in to comment.