#!/usr/local/bin/python2 class M(type): def __new__(cls, name, bases, attrs): cls.n = 0 return type.__new__(cls, name, bases, attrs) def __init__(self, name, bases, attrs): self.i = 1 self.d() print self.__class__ def d(self): print self.__class__ class C(object): __metaclass__ = M print M.n, C.i