Message301180
| Author |
Aaron Hall |
| Recipients |
Aaron Hall, JJeffries, eric.araujo, ezio.melotti, pconnell, rhettinger |
| Date |
2017年09月03日.03:56:02 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1504410963.2.0.645379017525.issue12154@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
It seems that this issue is still properly open. (Another open issue seems be related: http://bugs.python.org/issue30129)
In the docs on partial, we have:
>>> from functools import partial
>>> basetwo = partial(int, base=2)
>>> basetwo.__doc__ = 'convert base 2 string to int'
But the help function doesn't find that __doc__:
>>> help(basetwo)
class partial(builtins.object)
| partial(func, *args, **keywords) - new function with partial application
...
Perhaps this could be solved by having PyDoc check for isinstance of a Callable or making partial an instance of a Function?
>>> type(basetwo)
<class 'functools.partial'>
>>> basetwo.__dict__
{'__doc__': 'convert base 2 string to int'}
>>> type(basetwo)
<class 'functools.partial'>
>>> isinstance(basetwo, partial)
True
>>> from types import FunctionType; from collections import Callable
>>> isinstance(basetwo, FunctionType)
False
>>> isinstance(basetwo, Callable)
True
The partial repr seems to get us close:
>>> repr(basetwo)
"functools.partial(<class 'int'>, base=2)"
I haven't dug much further into this, but I'm interested in doing the work to finish it, and I don't think the patch submitted 6 years ago quite gets us there. Any other thoughts before I decide to give it a go? |
|