Message328006
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. |
|
Date |
User |
Action |
Args |
2018-10-18 21:21:51 | vstinner | set | recipients:
+ vstinner, chris.jerdonek, serhiy.storchaka, hongweipeng, xtreak |
2018-10-18 21:21:51 | vstinner | set | messageid: <1539897711.95.0.788709270274.issue34475@psf.upfronthosting.co.za> |
2018-10-18 21:21:51 | vstinner | link | issue34475 messages |
2018-10-18 21:21:51 | vstinner | create | |
|