[issue43310] Method __del__ with callable

Mark Dickinson report at bugs.python.org
Wed Feb 24 12:25:37 EST 2021


Mark Dickinson <dickinsm at gmail.com> added the comment:

The key difference between the func_del function and the instance C() is that func_del is a (non-data) descriptor in addition to being callable, while the instance C() is not. That makes func_del usable as a method.

If you define C as follows, you'll see the behaviour you expect:


    class C:
        def __call__(self, *args, **kwargs):
            print("call", args, kwargs)

        def __get__(self, obj, objtype=None):
              return MethodType(self, obj)

Useful reference for descriptors: https://docs.python.org/3/howto/descriptor.html

I'll close here, since this is neither a bug nor a feature request.

----------
nosy: +mark.dickinson
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

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


More information about the Python-bugs-list mailing list