[Python-Dev] accumulator display syntax
Armin Rigo
arigo at tunes.org
Fri Oct 17 14:28:11 EDT 2003
More information about the Python-Dev mailing list
Fri Oct 17 14:28:11 EDT 2003
- Previous message: [Python-Dev] accumulator display syntax
- Next message: [Python-Dev] accumulator display syntax
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hello, On Fri, Oct 17, 2003 at 11:55:53AM -0600, Shane Holloway (IEEE) wrote: > mygenerator = x for x in S > > for y in x for x in S: > print y > > return x for x in S Interesting but potentially confusing: we could expect the last one to mean that we executing 'return' repeatedly, i.e. returning a value more than once, which is not what occurs. Similarily, yield x for x in g() in a generator would be quite close to the syntax discussed some time ago to yield all the values yielded by a sub-generator g, but in your proposal it wouldn't have that meaning: it would only yield a single object, which happens to be an iterator with the same elements as g(). Even with parenthesis, and assuming a syntax to yield from a sub-generator for performance reason, the two syntaxes would be dangerously close: yield x for x in g() # means for x in g(): yield x yield (x for x in g()) # means yield g() Armin
- Previous message: [Python-Dev] accumulator display syntax
- Next message: [Python-Dev] accumulator display syntax
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-Dev mailing list