https://github.com/alecthomas/aspect
Lightweight Aspect-oriented Module for Python
https://github.com/alecthomas/aspect
Last synced: about 22 hours ago
JSON representation
Lightweight Aspect-oriented Module for Python
- Host: GitHub
- URL: https://github.com/alecthomas/aspect
- Owner: alecthomas
- Created: 2010-09-22T10:51:17.000Z (almost 16 years ago)
- Default Branch: master
- Last Pushed: 2024-01-01T17:41:00.000Z (over 2 years ago)
- Last Synced: 2025-10-09T00:40:45.594Z (9 months ago)
- Language: Python
- Homepage:
- Size: 2.93 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
Awesome Lists containing this project
README
Lightweight Aspect-oriented Module for Python
=============================================
Hooks advice to a function or method.
advise() is a decorator that takes a set of functions or methods and injects
the decorated function in their place. There is no concept of before/after
callbacks. Instead, the intercepting function is responsible for calling (or
not) the intercepted function.
The "classic" logging example::
class A(object):
def a_function(self):
print 'a_function()'
@advise(A.a_function)
def logit(on, next, *args, **kwargs):
logging.debug('%r.%r(%r, %r)', on, next, args, kwargs)
return next(*args, **kwargs)
See the function documentation for more information.