[issue20309] Not all method descriptors are callable

Simon Ruggier report at bugs.python.org
Wed Nov 21 19:34:05 EST 2018


Simon Ruggier <Simon.Ruggier at gmail.com> added the comment:

I hit this problem today with what I'd consider a valid use case: I wanted to use a static method as a default argument to a function on the same class. Within the class definition context, automatic unwrapping of the staticmethod object doesn't occur, so the default value ends up not being callable unless the staticmethod object is manually, explicitly unwrapped via __func__.

For those who prefer code to prose, I've attached example Python 2/3 code demonstrating what I mean.

The workaround is pretty easy, but on the other hand, it also looks like it would also be pretty straightforward to facilitate this use case without forcing the author to learn about this distinction and manually unwrap the static method, and I think it makes sense to do that.

----------
nosy: +sruggier
Added file: https://bugs.python.org/file47940/example_use_case.py

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


More information about the Python-bugs-list mailing list