Re: functools puzzle

2016-04-06 Thread Michael Selik
On Wed, Apr 6, 2016 at 8:16 PM George Trojan - NOAA Federal < george.tro...@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 o

Re: functools puzzle

2016-04-06 Thread George Trojan - NOAA Federal
True, but the pure Python and C implementation differ. Is that intentional? I find the current behaviour confusing. The doc states only that partial object does not set the __doc__ attribute, not that the attribute might be ignored. I had a peek at the pydoc module. It uses inspect to determine th

Re: functools puzzle

2016-04-06 Thread Michael Selik
> On Apr 6, 2016, at 6:57 PM, George Trojan - NOAA Federal > wrote: > > The module functools has partial() defined as above, then overrides the > definition by importing partial from _functools. That would explain the > above behaviour. My question is why? A couple speculations why an author m

Re: functools puzzle

2016-04-06 Thread Peter Otten
George Trojan - NOAA Federal wrote: > Here is my test program: > > ''' generic test ''' > > import functools > import inspect > > def f(): > '''I am f''' > pass > > g = functools.partial(f) > g.__doc__ = '''I am g''' > g.__name__ = 'g' > > def partial(func, *args, **keywords): > d

functools puzzle

2016-04-06 Thread George Trojan - NOAA Federal
Here is my test program: ''' generic test ''' import functools import inspect def f(): '''I am f''' pass g = functools.partial(f) g.__doc__ = '''I am g''' g.__name__ = 'g' def partial(func, *args, **keywords): def newfunc(*fargs, **fkeywords): newkeywords = keywords.copy()