On Tuesday, August 15, 2017 at 5:48:43 PM UTC+5:30, Steve D'Aprano wrote: > On Tue, 15 Aug 2017 02:54 pm, Rustom Mody wrote: > > > On Monday, August 14, 2017 at 10:35:22 PM UTC+5:30, Terry Reedy wrote: > [...] > >> Suppose stdin contains "a\nb\nc\nd\ne\nf\ng\n". > >> What is the meaning of > >> [input(f"response{i}") for i in range(6)]? > >> In Python, the predictable result is > >> ['a', 'b', 'c', 'd', 'e', 'f'] > >> It would not be with some of Rustom Mody's 'equivalents'. > > Indeed. Terry has hit the nail on the head here. Python's documented semantics > is predictable and deterministic, and the documented semantics of > comprehensions are explicitly based on sequential for-loops. > > To continue to insist, in contradiction to the documentation, that list comps > might legitimately operate in arbitrary order is simply irrational. If they > behaved as Rustom is insisting they might, it would be a bug in the > implementation.
I know that list-comps behave like the l2r-pass-doing-appends as SPECIFIED in the docs. In my view the IMPLEMENTATION is correct wrt that specification Whereas the SPECIFICATION, in being over-specific is wrong In the same way that if someone explaining C were to say that the '+' operator is (the SAME AS) ADD x86 instructions and then proves that case by showing gcc -S's output. -- https://mail.python.org/mailman/listinfo/python-list