statsmodels.tools.docstring_helpers.Substitution

class statsmodels.tools.docstring_helpers.Substitution(*args, **kwargs)[source]

A decorator to take a function’s docstring and perform string substitution on it.

This decorator is robust even if func.__doc__ is None (for example, if -OO was passed to the interpreter).

Usage: construct a Substitution with a sequence or dictionary suitable for performing substitution; then decorate a suitable function with the constructed object. e.g.

sub_author_name = Substitution(author=’Jason’)

@sub_author_name def some_function(x):

“%(author)s wrote this function”

# note that some_function.__doc__ is now “Jason wrote this function”

One can also use positional arguments:

sub_first_last_names = Substitution(‘Edgar Allen’, ‘Poe’)

@sub_first_last_names def some_function(x):

“%s %s wrote the Raven”

Parameters:
*argsstr

Positional arguments for %s-style substitution.

**kwargsstr

Keyword arguments for %(name)s-style substitution. Cannot be combined with positional args.

Methods

__call__(func)

Call self as a function.

Methods

update(*args, **kwargs)

Update self.params with supplied args.