English subtitles

← 02-26 Generator Expressions Solution

Get Embed Code
1 Language

Showing Revision 1 created 04/23/2012 by Amara Bot.

  1. [Norvig] The answer is no, I didn't try to confuse you.
  2. In fact, I'm trying to show you a very useful tool in generator expressions.
  3. Yes, I thought the indentation was important.
  4. With all those fors and ifs, I would have run out of space across the page.
  5. Yes, I wanted to stop early, and so a list comprehension would have been a bad idea
  6. because a list comprehension would have had to do all the work,
  7. whereas a generator expression can stop as soon as it's done.
  8. Having statements rather than expressions also would allow me to stop early.
  9. And yes, it's easier to edit.
  10. If I wanted to move around the order of the clauses,
  11. instead of having the indented structure that I would have with statements
  12. I have a flat structure and it's easy for me to pick out 1 of the constraints
  13. and move it somewhere else in the list
  14. without having to worry about getting the indentation right.
  15. So editing expressions is easier than editing statements in Python.