All pastes #594292 Raw Edit

Someone

public python v1 · immutable
#594292 ·published 2007-06-28 21:14 UTC
rendered paste body
class Protected(type):  def __init__(cls, name, bases, dct):    print 'in metaclass init'    classInit = dct['__init__']    print 'found key init:', classInit    def newInit( self, *args, **kwargs ):       print 'in new init'       classInit( self, *args, **kwargs )    dct['__init__'] = newInit    super(Protected, cls).__init__(name, bases, dct)class Foo:  __metaclass__ = Protected  def __init__(self):    print 'in Foo.init'    self.val = 123f = Foo()f.value = 999