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
[Bug] print(..., end="\r") doesn't produce any output #166
Carriage returns don't (normally) directly override the last line.
Subsequent text will overwrite the already printed text (or parts of it).
At least with forced flushing, it should print some-thing.
The common use case is to continuously print the state of the program:
This is an old issue, but I've found that using end='' with a carriage return at the beginning of a string produces the desired effect—overwriting the previous line—and is much simpler than the solutions linked above.
i.e. print('\ryour text here', end='')
Reacted by Robin Richtsfeld, Batu, sizhky, Andrew Wei, Abhishek Chatterjee, Muneeb Iqbal Vaiyani, nikhil, Mohamed Shahawy, Sander Bos, vijay-yajiv and 32 more
Reacted by Abhishek Chatterjee, Muneeb Iqbal Vaiyani, Sander Bos, vijay-yajiv, Emily Yunha Shin, Avi Jain, bang.vo, shlomi-schwartz, Broden Wanner, Uday Goyat and 8 more
Reacted by shlomi-schwartz, Broden Wanner, wakataw, jcanedo279, Ollin Boer Bohan, Jose Marcos RF and Renato Damas
Activity
blois commentedon May 23, 2018
Carriage returns are automatically clearing any contents back to the newline, regardless of what follows.
Is there a specific scenario in which more advanced handling is desired?
Androbin commentedon May 23, 2018
Carriage returns don't (normally) directly override the last line.
Subsequent text will overwrite the already printed text (or parts of it).
At least with forced flushing, it should print some-thing.
The common use case is to continuously print the state of the program:
This way, you don't spam the notebook output with pages of redundant logging.
blois commentedon May 23, 2018
Two examples of approaches for doing this:
https://colab.research.google.com/gist/blois/81711a73150e4fa1773782068fbb69ec/clearing-outputs.ipynb
Androbin commentedon May 23, 2018
Thanks! Good to know.
But I just noticed that
!pip installseems to have trouble printing:Running setup.py bdist_wheel for atari-py ... -� �\� �|� �/� �-� �\� �|� �/� �-� �\� �|� �/� �-� �\� �|� �/� �-� �\� �|� �/� �-� �\� �|� �/� �-� �\� �|� �/� �-� �\� �|� �/� �-� �\� �|� �/� �-� �\� �|� �/� �-� �\� �|� �/� �-� �\� �|� �/� �-� �\� �|� �/� �-� �\� �|� �/� �-� �\� �|� �/� �-� �\� �|� �/� �-� �\� �|� �/� �-� �\� �|� �/� �-� �\� �|� �/� �-� �\� �|� �/� �-� �\� �|� �/� �-� �\� �|� �/� �-� �\� �|� �/� �-� �\� �|� �/� �-� �\� �|� �done
It's supposed to animate the last symbol between - \ | / in place.
blois commentedon May 23, 2018
We fixed an issue with this about a week ago and I have no longer observed the issue during
!pip install.A simple repro of it working is:
https://colab.research.google.com/gist/blois/d8e4ae3df9eef1a8a99245403024883b/spinner.ipynb
If you happen to have an example of containing the final result then we can take a look at it.
Androbin commentedon May 23, 2018
I am able to reproduce with these three lines:
blois commentedon May 29, 2018
The fix will be rolling out in a few days, thank you for the report!
JSTHoffman commentedon Mar 11, 2020
This is an old issue, but I've found that using
end=''with a carriage return at the beginning of a string produces the desired effect—overwriting the previous line—and is much simpler than the solutions linked above.i.e.
print('\ryour text here', end='')