4 ms·
In the section "Inline -> Comprehension", isn't this: <iter> = (i+5 for i in range(10)) # (5, 6, ..., 14) really a generator expression?
by vram22 8y ago
In the section "Inline -> Comprehension", isn't this:
<iter> = (i+5 for i in range(10)) # (5, 6, ..., 14)
really a generator expression?
- pizzaburek 8y agoYes, although there is a saying that "every generator is an iterator, but not every iterator is a generator". But then again generator has a bunch of methods (close, gi_frame, gi_yieldfrom, throw, gi_code, gi_running, send) that iterators don't have... I really don't know if <iter> is correct enough here, or should I use <genr> (that I don't use anywhere else and could be confusing).
- x3tm 8y agoI would've written: <iter> = ( f(i) for i in <gen>) where f() is some function of i.