staticmethod
objects are not callable. They're descriptors that keep references to original functions in their __func__
attributes.
So the following works:
# Note: apply staticmethod again
fail_fax = staticmethod(partial(load_fax.__func__, error='PC LOAD LETTER'))
You could also define a helper function in the class namespace, to avoid unnecessary attribute lookups:
def _load_fax(fax, error=''):
# ...
# _load_fax is an ordinary function
load_fax = staticmethod(_load_fax)
fail_fax = staticmethod(partial(_load_fax, error='PC LOAD LETTER'))
Though the correct Python 3.4+ solution is to use the partialmethod
, which was designed to work with descriptors:
fail_fax = partialmethod(load_fax, error='PC LOAD LETTER')