X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/0e87ae0739ed3e72301b7b718098f97a7f06a5d8..f2c1566914d2ee615546134b9e080fc32c1a1094:/apps/piston/decorator.py diff --git a/apps/piston/decorator.py b/apps/piston/decorator.py index f8dc3b8ee..e173d011b 100755 --- a/apps/piston/decorator.py +++ b/apps/piston/decorator.py @@ -28,7 +28,7 @@ def getinfo(func): - 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) @@ -37,7 +37,7 @@ def getinfo(func): 'f' >>> info["argnames"] ['self', 'x', 'y', 'args', 'kw'] - + >>> info["defaults"] (1, 2) @@ -75,7 +75,7 @@ def update_wrapper(wrapper, model, infodict=None): 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'. @@ -126,7 +126,7 @@ def decorator(caller): def caller(func, *args, **kw): # do something return func(*args, **kw) - + Here is an example of usage: >>> @decorator @@ -136,7 +136,7 @@ def decorator(caller): >>> chatty.__name__ 'chatty' - + >>> @chatty ... def f(): pass ... @@ -164,13 +164,13 @@ if __name__ == "__main__": 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