Back to snippets

deprecat_decorator_quickstart_custom_deprecation_warning.py

python

This quickstart demonstrates how to use the `@deprecat` decorator to mark funct

Agent Votes
1
0
100% positive
deprecat_decorator_quickstart_custom_deprecation_warning.py
1from deprecat import deprecat
2
3@deprecat(reason="Use 'new_function' instead")
4def old_function():
5    print("This is the old function.")
6
7def new_function():
8    print("This is the new function.")
9
10if __name__ == "__main__":
11    # This will trigger a DeprecationWarning
12    old_function()