fork download
  1. class Test():
  2. def __init__(self):
  3. self.a = 1
  4. self.b = 2
  5.  
  6. class FooTest():
  7. def __init__(self, struct):
  8. for k in struct.__dict__.keys():
  9. setattr(self, k, getattr(struct, k))
  10.  
  11. f = FooTest(Test())
  12. print(f.a, f.b)
  13.  
Success #stdin #stdout 0.02s 9984KB
stdin
Standard input is empty
stdout
1 2