Anton Shestakov avatar 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.

Comments (0)

Files changed (1)

python 2/koans/about_generators.py

         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
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.