From 83aff01ac4a17fb104a3af4400160a083aab8ca2 Mon Sep 17 00:00:00 2001 From: Michele Simionato Date: Mon, 21 Sep 2015 16:34:21 +0200 Subject: Fixed the docs --- src/tests/documentation.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/tests/documentation.py b/src/tests/documentation.py index 81602c8..766c4c6 100644 --- a/src/tests/documentation.py +++ b/src/tests/documentation.py @@ -147,11 +147,14 @@ that depends on non-hashable arguments): $$memoize_uw -Here i used the functools.update_wrapper_ utility, which has +Here I used the functools.update_wrapper_ utility, which has been added in Python 2.5 expressly to simplify the definition of decorators (in older versions of Python you need to copy the function attributes ``__name__``, ``__doc__``, ``__module__`` and ``__dict__`` from the original function to the decorated function by hand). +Here is an example of usage: + +$$f1 .. _functools.update_wrapper: https://docs.python.org/3/library/functools.html#functools.update_wrapper -- cgit v1.2.1 From f1d2835e2745b19e8d984c0cb7defd527bd9e9e2 Mon Sep 17 00:00:00 2001 From: Michele Simionato Date: Fri, 25 Sep 2015 04:19:45 +0200 Subject: Added a docstring to the memoize example --- src/decorator.py | 2 +- src/tests/documentation.py | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/decorator.py b/src/decorator.py index 7a8b232..b9d3732 100644 --- a/src/decorator.py +++ b/src/decorator.py @@ -33,7 +33,7 @@ for the documentation. """ from __future__ import print_function -__version__ = '4.0.2' +__version__ = '4.0.3' import re import sys diff --git a/src/tests/documentation.py b/src/tests/documentation.py index 766c4c6..8156e3c 100644 --- a/src/tests/documentation.py +++ b/src/tests/documentation.py @@ -1233,6 +1233,11 @@ def _memoize(func, *args, **kw): def memoize(f): + """ + A simple memoize implementation. It works by adding a .cache dictionary + to the decorated function. The cache will grow indefinitely, so it is + your responsability to clear it, if needed. + """ f.cache = {} return decorate(f, _memoize) -- cgit v1.2.1