<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/a-master-class-in-decorators-patching-and-tracing-bt3chlbss" -->

---
title: A master class in decorators, patching and tracing
description: A new Workshops page collects seventy free, hands-on Python workshops across five collections covering decorators, wrapt (decorators, monkey patching, object...
canonical: https://daily.dev/posts/a-master-class-in-decorators-patching-and-tracing-bt3chlbss
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: A master class in decorators, patching and tracing | daily.dev
og:description: A new Workshops page collects seventy free, hands-on Python workshops across five collections covering decorators, wrapt (decorators, monkey patching, object...
og:url: https://daily.dev/posts/a-master-class-in-decorators-patching-and-tracing-bt3chlbss
og:image: https://api.daily.dev/og/posts/bT3chlBSS.png
og:image:alt: A master class in decorators, patching and tracing
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# A master class in decorators, patching and tracing

**[Planet Python](https://daily.dev/sources/planetpython)** · 8 min read · 0 upvotes · 0 comments

## Summary

A new Workshops page collects seventy free, hands-on Python workshops across five collections covering decorators, wrapt (decorators, monkey patching, object proxies), and wrapture (patching, testing, tracing). They run in JupyterLab via a custom jupyterlab-workshop extension, launchable through JupyterLite in-browser, mybinder.org, GitHub Codespaces, or locally, with no installation required to get started.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://grahamdumpleton.me/posts/2026/09/a-master-class-in-decorators-patching-and-tracing>

## Questions this post answers

### What's the difference between writing a decorator with the standard library versus using wrapt?

The standard library approach uses functools.wraps and manual wrapper functions, which breaks down when applied to methods, class methods, static methods, or classes themselves. Wrapt provides a wrapper function with an instance argument that tells you exactly what kind of callable is being decorated, handling per-instance caching, thread synchronization, and signature preservation that plain decorators get wrong.

_Developers comparing decorator approaches can find deeper practical breakdowns like this on daily.dev._

### How can I test code by wrapping real objects instead of mocking them with unittest.mock?

Wrapture lets you write tests by wrapping the real code and recording what it actually did, turning that recording into a test rather than replacing the real implementation with a mock. It supports converting existing unittest.mock-based test suites, handles async code and generators, and integrates with pytest, giving tests that exercise real behavior instead of stubbed assumptions.

_Anyone weighing mocking versus wrapping strategies for tests can track approaches like this on daily.dev._

### How can I trace a running Python application without modifying its code?

Wrapture supports tracing a program without changing it, letting a program narrate its own calls, recording each request to a Flask application as a tree of calls, analyzing traces in a notebook, finding slow code paths, exporting to OpenTelemetry, and following a single trace across two separate processes.

_Developers debugging production behavior can keep up with tracing techniques like these on daily.dev._

## Similar posts on daily.dev

- [Trying out wrapture](https://daily.dev/posts/trying-out-wrapture-qi1ktjmcu) · Planet Python · 0 upvotes · 0 comments
- [Supercharge your programming skills with Python superpowers](https://daily.dev/posts/supercharge-your-programming-skills-with-python-superpowers-hgoyiiyt7) · InfoWorld · 0 upvotes · 0 comments
- [Introducing wrapture](https://daily.dev/posts/introducing-wrapture-ohj3cvcws) · Planet Python · 1 upvotes · 1 comments
- [Python Decorators 101 Quiz – Real Python](https://daily.dev/posts/python-decorators-101-quiz-real-python-2aklxbbwm) · Real Python · 0 upvotes · 0 comments

---

Tags: [#python](https://daily.dev/tags/python)

[View this post on daily.dev](https://daily.dev/posts/a-master-class-in-decorators-patching-and-tracing-bt3chlbss)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"A master class in decorators, patching and tracing","url":"https://daily.dev/posts/a-master-class-in-decorators-patching-and-tracing-bt3chlbss","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/a-master-class-in-decorators-patching-and-tracing-bt3chlbss"},"datePublished":"2026-09-25T01:51:02.805Z","dateModified":"2026-09-25T01:51:24.757Z","description":"A new Workshops page collects seventy free, hands-on Python workshops across five collections covering decorators, wrapt (decorators, monkey patching, object...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/95eea9710aeaaba44478bfca291eac84?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/95eea9710aeaaba44478bfca291eac84?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Planet Python","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Planet Python","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/eac3cc584cb043b5a242d13752bd3d0c","url":"https://daily.dev/sources/planetpython"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/a-master-class-in-decorators-patching-and-tracing-bt3chlbss","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"python","timeRequired":"PT8M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Planet Python","item":"https://daily.dev/sources/planetpython"},{"@type":"ListItem","position":3,"name":"A master class in decorators, patching and tracing"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/a-master-class-in-decorators-patching-and-tracing-bt3chlbss#faq","mainEntity":[{"@type":"Question","name":"What's the difference between writing a decorator with the standard library versus using wrapt?","acceptedAnswer":{"@type":"Answer","text":"The standard library approach uses functools.wraps and manual wrapper functions, which breaks down when applied to methods, class methods, static methods, or classes themselves. Wrapt provides a wrapper function with an instance argument that tells you exactly what kind of callable is being decorated, handling per-instance caching, thread synchronization, and signature preservation that plain decorators get wrong. Developers comparing decorator approaches can find deeper practical breakdowns like this on daily.dev."}},{"@type":"Question","name":"How can I test code by wrapping real objects instead of mocking them with unittest.mock?","acceptedAnswer":{"@type":"Answer","text":"Wrapture lets you write tests by wrapping the real code and recording what it actually did, turning that recording into a test rather than replacing the real implementation with a mock. It supports converting existing unittest.mock-based test suites, handles async code and generators, and integrates with pytest, giving tests that exercise real behavior instead of stubbed assumptions. Anyone weighing mocking versus wrapping strategies for tests can track approaches like this on daily.dev."}},{"@type":"Question","name":"How can I trace a running Python application without modifying its code?","acceptedAnswer":{"@type":"Answer","text":"Wrapture supports tracing a program without changing it, letting a program narrate its own calls, recording each request to a Flask application as a tree of calls, analyzing traces in a notebook, finding slow code paths, exporting to OpenTelemetry, and following a single trace across two separate processes. Developers debugging production behavior can keep up with tracing techniques like these on daily.dev."}}]}
```

