On Sat, Nov 27, 2021 at 7:21 PM dn via Python-list <python-list@python.org> wrote: > The expression list is evaluated once; it should yield an iterable > object. An iterator is created for the result of the expression_list. > The suite is then executed once for each item provided by the iterator, > in the order returned by the iterator. Each item in turn is assigned to > the target list using the standard rules for assignments (see Assignment > statements), and then the suite is executed. When the items are > exhausted (which is immediately when the sequence is empty or an > iterator raises a StopIteration exception), the suite in the else > clause, if present, is executed, and the loop terminates. > ยป > https://docs.python.org/3/reference/compound_stmts.html#the-for-statement > > > That said, I'm wondering if all is strictly true when the > expression_list is a generator, which by definition features > lazy-execution rather than up-front list production. So, things may > depend upon the full-nature of the application.
Yes, it is. Evaluating a generator expression gives you a generator object, which is an iterable. ChrisA -- https://mail.python.org/mailman/listinfo/python-list