On Tuesday, October 21, 2003, at 01:58 PM, Raymond Hettinger wrote: > At one time, I got a lot of feedback on this from comp.lang.python. > Just about everyone found the brackets to be helpful and not > misleading, > the immediate presence of "yield" was more than enough to signal that > an iterator was being returned instead of a list: > > g = [yield (len(line),line) for line in file if len(line)>5] FWIW, that g is an iterator is *far* less surprising than the fact that yield turns a function into a generator. If it's okay that a yield in the body of a function change the function, why can't a yield in the body of a list comprehension change the list comprehension? It's a lot more noticeable, and people should know that "yield" signals something a little more tricky is going on. Also has good symmetry with the current meaning of yield. -- Ian Bicking | ianb at colorstudy.com | http://blog.ianbicking.org
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4