functools puzzle

Michael Selik michael.selik at gmail.com
Wed Apr 6 19:34:28 EDT 2016


On Wed, Apr 6, 2016 at 8:16 PM George Trojan - NOAA Federal <
george.trojan at noaa.gov> wrote:

> My basic question is how to document functions created by
> functools.partial, such that the documentation can be viewed not only by
> reading the code. Of course, as the last resort, I could create my own
> implementation (i.e. copy the pure Python code).
>

I don't think this is a complete solution, but it might get you a bit
closer.

    import functools
    import math

    def party(func, *args, **kwargs):
        d = {'__name__': func.__name__,
             '__doc__': func.__doc__,}
        partial = type('partial', (functools.partial,), d)
        foo = partial(func, *args, **kwargs)
        return foo

    exp = party(pow, math.e)
    help(exp)



More information about the Python-list mailing list