This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author andribas404
Recipients andribas404
Date 2021-02-24.06:44:13
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1614149053.65.0.947728004035.issue43310@roundup.psfhosted.org>
In-reply-to
Content
Is it possible to use callable to replace __del__ method of class?

if so, how to get self variable?

class A(object):
    """A."""


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


def func_del(*args, **kwargs):
    """Method."""
    print("func", args, kwargs)


def del_function():
    """
    Test del.

    ('func', (<__main__.A object at 0x7f8ae5a82750>,), {})
    ('call', (), {})
    """
    c = C()
    A.__del__ = func_del
    a = A()
    del a
    A.__del__ = c
    a = A()
    del a
History
Date User Action Args
2021-02-24 06:44:13andribas404setrecipients: + andribas404
2021-02-24 06:44:13andribas404setmessageid: <1614149053.65.0.947728004035.issue43310@roundup.psfhosted.org>
2021-02-24 06:44:13andribas404linkissue43310 messages
2021-02-24 06:44:13andribas404create