[BUG] One trailing newline ignored by rich.print in some cases
See original GitHub issueHi, thanks for this great library.
Not sure if this is expected behavior or a bug. In certain cases, rich.print
handles newlines in a slightly different manner than the print
built-in.
Example:
>>> for i in range(3): print('Hey' + '\n' * i)
...
Hey
Hey
Hey
>>> from rich import print
>>> for i in range(3): print('Hey' + '\n' * i)
...
Hey
Hey
Hey
>>>
Apparently, when the printed string contains at least one trailing newline (i.e. when i == 1
or i == 2
), one newline is ignored by rich.print
.
A screenshot of a similar example:
(rich 3.3.2, Python 3.8.0, GNOME Terminal 3.18.3 on Linux Mint 18.2 64-bit)
Issue Analytics
- State:
- Created 3 years ago
- Comments:6
Top Results From Across the Web
Trailing newline ignored · Issue #70 · tidyverse/glue - GitHub
I'm using glue for some codegen and I noticed it seems to trim a trailing newline. str(glue("\n")) ## empty string str(glue("\n\n")) ## one...
Read more >Full Text Bug Listing - Red Hat Bugzilla
I've obfuscated the passwords, but dbpwd is 29 characters, and the last character is a newline, which is strange, but perhaps valid in...
Read more >jinja2 how to remove trailing newline - python - Stack Overflow
You can avoid the trailing newline by first removing all newlines (using the minus signs at -%} and {%- in the for loop),...
Read more >Line breaks are removed in posts made in plain text format
Describes the behavior when line breaks are removed in a plain text format post without any indication in Outlook.
Read more >Your Guide to the Python print() Function
Sometimes you don't want to end your message with a trailing newline so that subsequent calls to print() will continue on the same...
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
Might be useful occasionally, but it would be difficult to test control codes and differences across platforms with doctests.
There are tests now for this case btw.
Btw I don’t know if you use
doctest
in your project, but this kind of output in the interactive interpreter can be easily tested with it, e.g.: