t354.py 267 B

123456789101112131415161718
  1. class A:
  2. val1 = "A"
  3. def __init__(self, v):
  4. self.val1 = v
  5. def do(self):
  6. print self.__class__.val1
  7. print self.val1
  8. def update(self, newv):
  9. self.val1 = newv
  10. print "===A==="
  11. a = A("sa")
  12. a.do()
  13. a.update("sa-new")
  14. a.do()