[Python-Dev] accumulator display syntax
Guido van Rossum
guido at python.org
Fri Oct 17 18:47:28 EDT 2003
More information about the Python-Dev mailing list
Fri Oct 17 18:47:28 EDT 2003
- Previous message: [Python-Dev] accumulator display syntax
- Next message: [Python-Dev] accumulator display syntax
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
> Hm. What if list comprehensions returned a "lazy list", that if you took > an iterator of it, you'd get a generator-iterator, but if you tried to use > it as a list, it would populate itself? Then there'd be no need to ever > *not* use a listcomp, and only one syntax would be necessary. > > More specifically, if all you did with the list was iterate over it, and > then throw it away, it would never actually populate itself. The principle > drawback to this idea from a semantic viewpoint is that listcomps can be > done over expressions that have side-effects. :( I don't think this can be done without breaking b/w compatibility. Example: a = [x**2 for x in range(10)] for i in a: print i print a Your proposed semantics would throw away the values in the for loop, so what would it print in the third line? --Guido van Rossum (home page: http://www.python.org/~guido/)
- 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