Skip to content

Comments

gh-49989: Add equivalent code for the "for" statement#145067

Draft
serhiy-storchaka wants to merge 1 commit intopython:mainfrom
serhiy-storchaka:docs-for-loop-equivalent-code
Draft

gh-49989: Add equivalent code for the "for" statement#145067
serhiy-storchaka wants to merge 1 commit intopython:mainfrom
serhiy-storchaka:docs-for-loop-equivalent-code

Conversation

@serhiy-storchaka
Copy link
Member

@serhiy-storchaka serhiy-storchaka commented Feb 21, 2026

@serhiy-storchaka serhiy-storchaka force-pushed the docs-for-loop-equivalent-code branch from b90750b to a1bcd01 Compare February 21, 2026 10:48

while running:
try:
TARGET = iter.__next__()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
TARGET = iter.__next__()
TARGET = it.__next__()

You have it = (ITER).__iter__() above?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I experimented with using iter() and next(), but kept explicit special methods for clarity.

On other hand, iter() is not just calling __iter__(), it works also with sequences without __iter__(), so it may be better to use it for accuracy. Then we have issue with references...

@serhiy-storchaka serhiy-storchaka marked this pull request as draft February 21, 2026 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation in the Doc dir needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes skip news

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

2 participants