t410.py 188 B

123456789101112
  1. class F():
  2. def __init__(self):
  3. self.a = 1
  4. self.b = 2
  5. self.d = 4
  6. f = F()
  7. print getattr(f,'a')
  8. print getattr(f,'b')
  9. print getattr(f,'c',3)
  10. print getattr(f,'d')