[Python-ideas] Re: Add __name__ to functools.partial object

2022-08-29 Thread Wes Turner
Is there a non-performance regressive way to proxy attr access to func.__name__ of the partial function (or method; Callable)? Would this affect documentation generation tools like e.g. sphinx-spidoc, which IIRC use __name__ and probably now __qualname__ for generating argspecs in RST for HTML and

[Python-ideas] Re: Add __name__ to functools.partial object

2022-08-29 Thread Charles Machalow
1: There are cases where one may need the __name__/__qualname__ of a given callable. If someone uses partial to create a new callable, there is no __name__/__qualname__ given. In my particular case, I'm logging what callback function is passed to a different function... if someone uses partial, the

[Python-ideas] Re: Add __name__ to functools.partial object

2022-08-29 Thread Paul Bryan
+0 Questions: 1. What's the use case for partial having __name__? 2. Does this imply it should have __qualname__ as well? 3. What name would be given to (an inherently anonymous) lambda? Notes: 1. I would prefer __name__ to be more qualifying like its repr (e.g. partial(foo, "x") → "") On Mon

[Python-ideas] Add __name__ to functools.partial object

2022-08-29 Thread Charles Machalow
Hey folks, I propose adding __name__ to functools.partial. >>> get_name = functools.partial(input, "name: ") >>> get_name() name: hi 'hi' >>> get_name.__name__ Traceback (most recent call last): File "", line 1, in AttributeError: 'functools.partial' object has no attribute '__name__' >>> get_