[New-bugs-announce] [issue4113] functools.partial(), no __name__; wrong __doc__

Andrew Stribblehill report at bugs.python.org
Mon Oct 13 13:45:15 CEST 2008

New submission from Andrew Stribblehill <ads at wompom.org>:

When I partially apply a function using functools.partial(), the
resultant function doesn't have the same name as the original function
(it has no __name__) and its docstring is that of functools.partial()
rather than that of the function that was partially applied.


Python 2.6 (r26:66714, Oct 13 2008, 10:32:02)
[GCC 4.0.3 (Ubuntu 4.0.3-1ubuntu5)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>> import functools
>>> def sum(a,b,c):
...   return a+b+c
>>> functools.partial(sum,1)
<functools.partial object at 0xf7efeb6c>
>>> p = functools.partial(sum, 1)
>>> p.__name__
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'functools.partial' object has no attribute '__name__'
>>> p(2,3)
>>> sum.__name__
>>> sum.__doc__
>>> p.__doc__
'partial(func, *args, **keywords) - new function with partial
application\n\tof the given arguments and keywords.\n'

components: Extension Modules
messages: 74682
nosy: stribb
severity: normal
status: open
title: functools.partial(), no __name__; wrong __doc__
type: behavior
versions: Python 2.6

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list