Anton Shestakov  committed 6cd0f25

This koan should make an example of difference between generators and lists by testing both at the same job.

self.assertRaises(___, num_generator, [0]) raises "TypeError: 'generator' object is not callable" — list is not callable either, so the error shows nothing unexpected.
self.assertRaises(___, num_generator[0]) raises "TypeError: 'generator' object is not subscriptable" — now this is significant.

  • Participants
  • Parent commits 81e0997
  • Branches default

Comments (0)

Files changed (1)

File python 2/koans/

         self.assertEqual(2, num_list[0])
         # A generator has to be iterated through.
-        self.assertRaises(___, num_generator, [0]) # Evaluates num_generator[0]
+        self.assertRaises(___, num_generator[0]) # Evaluates num_generator[0]
         self.assertEqual(__, list(num_generator)[0]) # This works though
         # Both list comprehensions and generators can be iterated though. However, a generator