metaclasses

Dmitri Mouromtsev dimour at mail.ru
Thu Feb 27 09:17:37 CET 2003


Hello all!

I've tried to override __del__ method for class object, but nothing to
happen. Why? Does the __del__ method called when class object deleted or
not?

Here is example of my code:
class MyMetaclass(type):

    def __init__(cls, name, bases, dict):

        super(MyMetaclass, cls).__init__(name, bases, dict)

        print 'initialized'

    def __del__(cls):

        print 'deleted'

class MyClass(object):

    __metaclass__ = MyMetaclass

class Sub(MyClass):

    pass

del Sub



Thanks
Dmitri






More information about the Python-list mailing list