Metaclass Example : Introduction : Class PYTHON TUTORIALS


PYTHON TUTORIALS » Class » Introduction »

 

Metaclass Example


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()



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON TUTORIALS

 Navioo Class
» Introduction