From e5fc05e9b054869e8d7c16d49eba9131bf078fb6 Mon Sep 17 00:00:00 2001 From: Mark Pilgrim Date: Thu, 16 Jul 2009 23:28:06 -0400 Subject: [PATCH] xref --- advanced-iterators.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/advanced-iterators.html b/advanced-iterators.html index da407d7..d613676 100755 --- a/advanced-iterators.html +++ b/advanced-iterators.html @@ -205,7 +205,7 @@ AssertionError: Only for very large values of 2 >>> tuple(ord(c) for c in unique_characters) (69, 68, 77, 79, 78, 83, 82, 89)
    -
  1. A generator expression is like an anonymous function that yields values. The expression itself looks like a list comprehension [FIXME have we introduced this yet?], but it’s wrapped in parentheses instead of square brackets. +
  2. A generator expression is like an anonymous function that yields values. The expression itself looks like a list comprehension [FIXME xref], but it’s wrapped in parentheses instead of square brackets.
  3. The generator expression returns… an iterator.
  4. Calling next(gen) returns the next value from the iterator.
  5. If you like, you can iterate through all the possible values and return a tuple, list, or set, by passing the generator expression to tuple(), list(), or set(). In these cases, you don’t need an extra set of parentheses — just pass the “bare” expression ord(c) for c in unique_characters to the tuple() function, and Python figures out that it’s a generator expression.