- doc (the docstring : str)
- module (the module name : str)
- dict (the function __dict__ : str)
-
+
>>> def f(self, x=1, y=2, *args, **kw): pass
>>> info = getinfo(f)
'f'
>>> info["argnames"]
['self', 'x', 'y', 'args', 'kw']
-
+
>>> info["defaults"]
(1, 2)
def new_wrapper(wrapper, model):
"""
An improvement over functools.update_wrapper. The wrapper is a generic
- callable object. It works by generating a copy of the wrapper with the
+ callable object. It works by generating a copy of the wrapper with the
right signature and by updating the copy, not the original.
Moreovoer, 'model' can be a dictionary with keys 'name', 'doc', 'module',
'dict', 'defaults'.
def caller(func, *args, **kw):
# do something
return func(*args, **kw)
-
+
Here is an example of usage:
>>> @decorator
>>> chatty.__name__
'chatty'
-
+
>>> @chatty
... def f(): pass
...
import doctest; doctest.testmod()
########################## LEGALESE ###############################
-
-## Redistributions of source code must retain the above copyright
+
+## Redistributions of source code must retain the above copyright
## notice, this list of conditions and the following disclaimer.
## Redistributions in bytecode form must reproduce the above copyright
## notice, this list of conditions and the following disclaimer in
## the documentation and/or other materials provided with the
-## distribution.
+## distribution.
## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
## "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT