t902.py 552 B

12345678910111213141516171819202122232425262728293031323334353637
  1. import collections
  2. try:
  3. print collections.defaultdict(1)
  4. except TypeError as e:
  5. print e
  6. try:
  7. print collections.defaultdict(list(), {})
  8. except TypeError as e:
  9. print e
  10. try:
  11. print collections.defaultdict(list, 12)
  12. except TypeError as e:
  13. print e
  14. try:
  15. d = collections.defaultdict(None)
  16. print d[5]
  17. except KeyError as e:
  18. print e
  19. try:
  20. print d.get(5)
  21. except TypeError as e:
  22. print e
  23. try:
  24. d.__missing__(1, 2)
  25. except TypeError as e:
  26. print e
  27. try:
  28. d.__missing__({1:2})
  29. except KeyError as e:
  30. print e