Skip to content

Commit cd29883

Browse files
Add code example for accessing decorator state.
1 parent b4cf7c5 commit cd29883

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

docs/decorators.rst

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,14 @@ of ``@wrapt.decorator``. It intercepts descriptor binding so that
292292
when the wrapper method is accessed through an instance of the state class,
293293
the state instance is automatically stored on the resulting wrapper as a
294294
named attribute. The ``name`` keyword argument controls the attribute name,
295-
allowing the state to be reached from the decorated function as
296-
``function.tracker``.
295+
allowing the state to be reached from the decorated function.
296+
297+
::
298+
299+
>>> function()
300+
>>> function()
301+
>>> function.tracker.call_count
302+
2
297303

298304
For a more detailed treatment of this pattern, including how it composes
299305
with instance methods, class methods and static methods, and how to support

0 commit comments

Comments
 (0)