nltk.decorator()
¶
-
nltk.
decorator
(caller)[source]¶ General purpose decorator factory: takes a caller function as input and returns a decorator with the same attributes. A caller function is any function like this:
def caller(func, *args, **kw): # do something return func(*args, **kw)
Here is an example of usage:
>>> @decorator ... def chatty(f, *args, **kw): ... print("Calling %r" % f.__name__) ... return f(*args, **kw)
>>> chatty.__name__ 'chatty'
>>> @chatty ... def f(): pass ... >>> f() Calling 'f'
decorator can also take in input a class with a .caller method; in this case it converts the class into a factory of callable decorator objects. See the documentation for an example.