> There are some callables which are missing __qualname__:
>
> method_descriptor
> wrapper_descriptor
> builtin_function_or_method
>
> For the descriptors, at least, obj.__qualname__ should be equivalent to
>
> obj.__objclass__.__qualname__ + '.' + obj.__name__
>
> Were these overlooked?
Indeed, they were overlooked. Due to the way they are instantiated,
though, it would be quite a bit harder to devise a __qualname__ for
them.
> Also I notice that bound methods have a misleading __qualname__:
>
> >>> class A:
> ... def f(self): pass
> ...
> [66348 refs]
> >>> A().f.__qualname__
> 'A.f'
>
> Maybe this should be 'A().f' instead.
I am a bit surprised that this works at all. Apparently attribute
lookups are redirected to the underlying function. |