[issue34475] functools.partial objects have no __qualname__ attribute

STINNER Victor report at bugs.python.org
Thu Oct 18 17:21:51 EDT 2018


STINNER Victor <vstinner at redhat.com> added the comment:

functools.partial objects have no __qualname__ attribute, but they don't have a __name__ attribute neither.

$ python3
Python 3.6.6 (default, Jul 19 2018, 14:25:17) 
>>> import functools
>>> func=int
>>> p=functools.partial(func)
>>> p.__name__
AttributeError: 'functools.partial' object has no attribute '__name__'
>>> p.__qualname__
AttributeError: 'functools.partial' object has no attribute '__qualname__'
>>> repr(p)
"functools.partial(<class 'int'>)"

If you want to "inherit" the name of the "wrapped function", you may use: functools.update_wrapper().

I'm not sure that it's correct to inherit the name by default. functools.partial() creates a new function, so if it has a name, for me, it should be different.

I agree to close the issue, it's not a bug.

----------
nosy: +vstinner

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue34475>
_______________________________________


More information about the Python-bugs-list mailing list