from time import ctime class MetaC(type): def __init__(cls, name, bases, attrd): super(MetaC, cls).__init__(name, bases, attrd) print ' Created class %r at: %s' % (name, ctime()) class Foo(object): __metaclass__ = MetaC def __init__(self): print 'Instantiated class %r at: %s' % (self.__class__.__name__, ctime()) f = Foo()
11.1.Introduction | ||||
11.1.1. | Common operator overloading methods | |||
11.1.2. | Double Underscore __ | |||
11.1.3. | Special Class Attributes | |||
11.1.4. | __dict__ is a dictionary representing its attributes: | |||
11.1.5. | Special Instance Attributes | |||
11.1.6. | Built-in Type Attributes | |||
11.1.7. | Metaclass Example | |||
11.1.8. | Related Modules and Documentation |