FastIO output gets truncated in windows terminal
See original GitHub issuePython Version: Python 3.7.7
Describe the bug Output gets truncated when printing a large amount of data over stdout (no problem with file I/O).
To Reproduce
Copy FastIO.py
from this repo to local, append these lines to the end of the file:
for x in range(5000):
print(f"{x:0>7} Hello world!")
Expected behaviour
It should print from 0000000 Hello world!
to 0004999 Hello world!
.
Additional context I change the lines above to this:
for x in range(5000):
print(f"{x:0>7} Hello world!")
if x % 1000 == 0: # ofcoz, 1000 doesn't always work
print(flush=True)
It works fine. This is error-prone. So I would like to ask whether it is possible to flush the output automatically whenever needed?
Thanks in advanced.
Issue Analytics
- State:
- Created 2 years ago
- Comments:7
Top Results From Across the Web
Powershell truncates my output, how do I make it NEVER do ...
When this happens, it collapses extra content into a "..." so everything fits in the width of the console. Here's an example with...
Read more >Output from WSL command pipeline is randomly truncated
The output is truncated? One of the programs in the pipeline is aborted early? It might be a timing issue? Repeating the last...
Read more >Powershell cmd /c Output Truncated - TechNet - Microsoft
I'm pulling output from the command below into an array, bit it's being truncated at 20 items ( or 863 characters if i...
Read more >See Everything In The Terminal/Command Prompt After Long ...
Inside your Terminal Window, go to Edit | Profile Preferences , click on the Scrolling tab, and check the Unlimited checkbox underneath the ......
Read more >Terminal output truncated to 80 symbols : IDEA-117552
Output in "Terminal" window is truncated to 80 characters. Attachments 1 ... I get this when running cygwin bash.exe from IntelliJ Terminal window....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The reason why this fails is a stupid quirk with this specific implementation of FastIO. The problem is that since the file object is not stored anywhere, it gets garbage collected and is automatically closed. I told @cheran-senthil about this issue back when FastIO was added to pyrival, but he didn’t bother fixing it/ didn’t think it mattered. The fix is easy, just store the file object somewhere
If I write like this:
it gives an error:
is it as expected?