The Python interpreter looks for string literals only. Adding a .format()
method call is not supported, not for the function definition syntax. It is the compiler that parses out the docstring, not the interpreter, and any variables like weightings
are not available at that time; no code execution takes place at this time.
You can always update a docstring after the fact:
def apply_weighting(self, weighting):
"""
Available functions: {}
"""
apply_weighting.__doc__ = apply_weighting.__doc__.format(weightings)