export_method

sherpa.utils.export_method(meth, name=None, modname=None)[source] [edit on github]

Given a bound instance method, return a simple function that wraps it. The only difference between the interface of the original method and the generated function is that the latter doesn’t include ‘self’ in its argument list. This means that when the wrapper function is called with an incorrect number of arguments, the error message does not include ‘self’ in argument counts. The only reason to generate such a wrapper is to hide from a user the fact that they’re using an instance method rather than a simple function. If meth is not an instance method, it is returned unchanged.

If name is None, the generated function will have the same name as the input method. Otherwise, name must be a string containing the desired name of the new method. If modname is not None, it must be a string and will be used as the module name for the generated function. Note that the caller is responsible for assigning the returned function to an appropriate name in the calling scope.