You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
REPL: Prompt obscures chars for print with end="," #136553
*sigh*
Clearly you didn't read my last statement in that I have retyped the
example multiple times. I looked for ANY misplaced commas or anything and
found nothing.
And no I DIDN'T put a, b = 1, 2. I am using 0, 1.
I'll include screenshots when I get home from work in ~6 hours.
I also see the documented output when running the example. It could be possible that your terminal is swallowing the first two values for some reason.
Got to section 3.2 on the tutorial.pdf document.
PDF? I'm not sure we even ship PDFs of the docs. I guess there's a chance the example is wrong if you got it from a third-party. What happens when you run the example from the official docs?
Looks like your terminal is having issues with the output not ending in a newline, and is printing the next prompt on top of the output. The four characters of the prompt (>>> ) are covering the first four characters of the output (0,1,). Usually, the prompt should be printed after the output, like this:
Hey Brian,
About: Windows Terminal, Version: 1.22.11141.0
OS: Windows 11 Home, Version: 24H2, OS build: 26100.4652
Processor: 11th Gen Intel(R) Core(TM) i7-1185G7 @ 3.00GHz
Tablet: Surface Pro 8
Would you like any other information?
And you are correct that the prompt is covering the values. The added
print() did show the missing numbers. But it is interesting...
Let me know if you need anything more.
On Fri, Jul 11, 2025 at 5:11 PM Brian Schubert ***@***.***> wrote:
*brianschubert* left a comment (python/cpython#136553)
<#136553 (comment)>
Looks like your terminal is having issues with the output not ending in a
newline, and is printing the next prompt on top of the output. The four
characters of the prompt (>>> ) are covering the first four characters of
the output (0,1,). Usually, the prompt should be printed after the
output, like this:
>>> a, b = 0, 1
... while a < 1000:
... print(a, end=',')
... a, b = b, a+b
... 0,1,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987,>>>
Sharing details about your terminal / environment would probably be
helpful to confirm whether this is an issue with your terminal or with
CPython.
As a workaround, you can try adding a call to print() immediately after
the while loop to force the prompt onto the next line.
—
Reply to this email directly, view it on GitHub
<#136553 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AALVXZL5JCQ7ZAVZZTFS53T3IBHEVAVCNFSM6AAAAACBKKMCFKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTANRUGM2DMMZXGI>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
This is a duplicate of at least one issue which must also have been closed without doing anything. For Python as default installed or compiled on Windows, the output for this example is wrong and should be fixed. Either add
else:
print()
to the while statement to print a final newline, which would be the proper thing to do in practice, or also give the Windows output.
The bug only exists in interactive shells in windows. This is how it works on my linux machine:
And in the window case, if we use a print() at the end we can avoid this:
I suggest to add the change in docs. This will cause some confusion IMO. (I think testing example case in windows interactive shells is pretty common) OR specify the unintended case in windows.
We could update the example, but ideally Windows shouldn't be overwriting those first few characters in the first place. Is there any way to prevent it from doing that? (cc @zooba@chris-eibl)
changed the title [-]Different output for tutorial 3.2 First Steps Towards Programming[/-][+]REPL: Prompt obscures chars for print with end=","[/+]on Jul 12, 2025
We could update the example, but ideally Windows shouldn't be overwriting those first few characters in the first place.
Maybe we can solve this in separate PRs? I will create a PR for doc fix later since it's easy to do. IMO it's better to specify the bug case in windows in doc.
We could update the example, but ideally Windows shouldn't be overwriting those first few characters in the first place. Is there any way to prevent it from doing that? (cc @zooba@chris-eibl)
This is definitely a bug of the new REPL on Windows. I can reproduce it for 3.13 and 3.14 in both a legacy and the new windows terminal. Setting the environment variable PYTHON_BASIC_REPL=1 before invoking python.exe switches back to the old REPL, which doesn't exhibit this bug on Windows.
See the linked issue above which has links to even more duplicates.
Activity
hugovk commentedon Jul 11, 2025
I've checked and the docs are correct, you may have mistyped or forgotten a line.
Double check your initial values of
aandb-- make sure you calleda, b = 0, 1at the start.Your output is consistent with starting with
a, b = 1, 2instead.Please open a topic in the help forum to ask further questions about this:
https://discuss.python.org/c/help/7
novocode commentedon Jul 11, 2025
ZeroIntensity commentedon Jul 11, 2025
I also see the documented output when running the example. It could be possible that your terminal is swallowing the first two values for some reason.
PDF? I'm not sure we even ship PDFs of the docs. I guess there's a chance the example is wrong if you got it from a third-party. What happens when you run the example from the official docs?
hugovk commentedon Jul 11, 2025
PDFs are here: https://docs.python.org/3/download.html
ZeroIntensity commentedon Jul 11, 2025
TIL!
novocode commentedon Jul 11, 2025
Here is the screenshot as promised
If you need tablet specs, os specs, etc, let me know.
brianschubert commentedon Jul 12, 2025
Looks like your terminal is having issues with the output not ending in a newline, and is printing the next prompt on top of the output. The four characters of the prompt (
>>>) are covering the first four characters of the output (0,1,). Usually, the prompt should be printed after the output, like this:Sharing details about your terminal / environment would probably be helpful to confirm whether this is an issue with your terminal or with CPython.
As a workaround, you can try adding a call to
print()immediately after the while loop to force the prompt onto the next line.novocode commentedon Jul 12, 2025
terryjreedy commentedon Jul 12, 2025
This is a duplicate of at least one issue which must also have been closed without doing anything. For Python as default installed or compiled on Windows, the output for this example is wrong and should be fixed. Either add
to the while statement to print a final newline, which would be the proper thing to do in practice, or also give the Windows output.
LamentXU123 commentedon Jul 12, 2025
The bug only exists in interactive shells in windows. This is how it works on my linux machine:
And in the window case, if we use a print() at the end we can avoid this:
I suggest to add the change in docs. This will cause some confusion IMO. (I think testing example case in windows interactive shells is pretty common) OR specify the unintended case in windows.
ZeroIntensity commentedon Jul 12, 2025
We could update the example, but ideally Windows shouldn't be overwriting those first few characters in the first place. Is there any way to prevent it from doing that? (cc @zooba @chris-eibl)
[-]Different output for tutorial 3.2 First Steps Towards Programming[/-][+]REPL: Prompt obscures chars for print with end=","[/+]LamentXU123 commentedon Jul 12, 2025
Maybe we can solve this in separate PRs? I will create a PR for doc fix later since it's easy to do. IMO it's better to specify the bug case in windows in doc.
picnixz commentedon Jul 12, 2025
This is a duplicate of #128067.
chris-eibl commentedon Jul 12, 2025
This is definitely a bug of the new REPL on Windows. I can reproduce it for 3.13 and 3.14 in both a legacy and the new windows terminal. Setting the environment variable
PYTHON_BASIC_REPL=1before invokingpython.exeswitches back to the old REPL, which doesn't exhibit this bug on Windows.See the linked issue above which has links to even more duplicates.
terryjreedy commentedon Jul 13, 2025
I did not realize before that this is new. A loop is not needed to reproduce. In 3.8, for instance:
Currently,
>>>covers1,.