t463.py 504 B

12345678910111213141516171819202122232425262728293031
  1. import math
  2. class F():
  3. def __init__(self):
  4. self.a = 1
  5. self.b = 2
  6. self.d = 4
  7. f = F()
  8. print hasattr(f,'a')
  9. print hasattr(f,'c')
  10. print hasattr(f,'D')
  11. try:
  12. print hasattr(f,b)
  13. print "You shouldn't see this."
  14. except:
  15. print hasattr(f,'b')
  16. print
  17. print hasattr(str,'center');
  18. print hasattr(str,'ljust');
  19. print
  20. print hasattr(math,'pi');
  21. print hasattr(math,'tau');
  22. try:
  23. print hasattr(math,None);
  24. print "You shouldn't see this."
  25. except:
  26. print hasattr(F,'a');