The Python Papers

The Python Papers

Share this post

The Python Papers
The Python Papers
Python 201 - How to use functools.wraps
Copy link
Facebook
Email
Notes
More

Python 201 - How to use functools.wraps

Making Decorators Better!

Mike Driscoll's avatar
Mike Driscoll
Feb 25, 2025
∙ Paid
5

Share this post

The Python Papers
The Python Papers
Python 201 - How to use functools.wraps
Copy link
Facebook
Email
Notes
More
2
Share

There is a little known tool that I wanted to talk about today. It is called wraps and it’s a part of the functools module. You can use wraps as a decorator to fix docstrings and names of decorated functions. Why does this matter? This sounds like a weird edge case at first, but if you’re writing an API or any code that someone other than yourself will …

Keep reading with a 7-day free trial

Subscribe to The Python Papers to keep reading this post and get 7 days of free access to the full post archives.

Already a paid subscriber? Sign in
© 2025 Mike Driscoll
Privacy ∙ Terms ∙ Collection notice
Start writingGet the app
Substack is the home for great culture

Share

Copy link
Facebook
Email
Notes
More