File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed
Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -176,6 +176,31 @@ statement executed in the first suite skips the rest of the suite and continues
176176with the next item, or with the :keyword: `!else ` clause if there is no next
177177item.
178178
179+ The following code::
180+
181+ for TARGET in ITER:
182+ SUITE
183+ else:
184+ SUITE2
185+
186+ Is semantically equivalent to::
187+
188+ it = (ITER).__iter__()
189+ running = True
190+
191+ while running:
192+ try:
193+ TARGET = iter.__next__()
194+ except StopIteration:
195+ running = False
196+ else:
197+ SUITE
198+ else:
199+ SUITE2
200+
201+ except that implicit :ref: `special method lookup <special-lookup >` is used
202+ for :meth: `~object.__iter__ ` and :meth: `~iterator.__next__ `.
203+
179204The for-loop makes assignments to the variables in the target list.
180205This overwrites all previous assignments to those variables including
181206those made in the suite of the for-loop::
You can’t perform that action at this time.
0 commit comments