Skip to content

Docs: the result of running example code of itertools.tee is not correct #128372

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

Closed
Snoopy1866 opened this issue Dec 31, 2024 · 3 comments
Closed
Labels
docs Documentation in the Doc dir OS-windows

Comments

@Snoopy1866
Copy link

Snoopy1866 commented Dec 31, 2024

Documentation

I’m using Python 3.13 and learning about itertools.tee from the official Python documentation. I copied the example code for the lookahead function, but when I ran it in the REPL, the output wasn’t the same as described in the documentation.

Look at the pictures below for more details about the diffrent output between REPL and documentation.

image

image

Enviroment

  • Windows 11 23H2 22631.4602
  • Python 3.13.0 (tags/v3.13.0:60403a5, Oct 7 2024, 09:38:07) [MSC v.1941 64 bit (AMD64)] on win32
@Snoopy1866 Snoopy1866 added the docs Documentation in the Doc dir label Dec 31, 2024
@Snoopy1866 Snoopy1866 changed the title docs: the result of running example code of itertools.tee is not correct Docs: the result of running example code of itertools.tee is not correct Dec 31, 2024
@skirpichev
Copy link
Member

Can't reproduce this on Linux:

>>> from itertools import tee
>>> def lookahead(tee_iterator):
...      "Return the next value without moving the input forward"
...      [forked_iterator] = tee(tee_iterator, 1)
...      return next(forked_iterator)
...      
>>> iterator = iter('abcdef')
>>> [iterator] = tee(iterator, 1)
>>> next(iterator)
'a'
>>> lookahead(iterator)
'b'
>>> next(iterator)
'b'

Can you try latest 3.13 release?

@Snoopy1866
Copy link
Author

Snoopy1866 commented Dec 31, 2024

I upgrade to python 3.13.1 and it works well, thanks!
image

@skirpichev
Copy link
Member

Ah, it seems this is just an instance of #123884.

Duplicate of #126701.

@skirpichev skirpichev closed this as not planned Won't fix, can't repro, duplicate, stale Dec 31, 2024
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 OS-windows
Projects
Status: Todo
Development

No branches or pull requests

2 participants