fork download
  1. def double_dec(cls):
  2. class Wrapper(cls):
  3. def __init__(self, val):
  4. super(Wrapper, self).__init__()
  5. self.double = 2 * val
  6.  
  7. return Wrapper
  8.  
  9. @double_dec
  10. class C(object):
  11. def __init__(self):
  12. print ('hello')
  13.  
  14. tmp = C(4)
  15. print (tmp.double)
  16.  
Success #stdin #stdout 0.02s 9136KB
stdin
Standard input is empty
stdout
hello
8