Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove example using next(...) from README #1516

Merged
merged 1 commit into from
Jan 14, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,7 @@ For example, to access the raw text from the AG_NEWS dataset:

>>> from torchtext.datasets import AG_NEWS
>>> train_iter = AG_NEWS(split='train')
>>> next(train_iter)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can still do next(iter(train)). Maybe we can change it to that instead?

Copy link
Contributor Author

@erip erip Jan 13, 2022

Choose a reason for hiding this comment

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

This is true, but calling iter(...) first will make an exhaustible iterator, right? This could introduce misleading usages which result in issues like #1447. I may be wrong, though. If I'm off-base, I can change the README as your recommend.

>>> # Or iterate with for loop
>>> # Iterate with for loop
>>> for (label, line) in train_iter:
>>> print(label, line)
>>> # Or send to DataLoader
Expand Down