print() to a file is senstive to shell terminal carriage size #3570
Unanswered
scottb5612
asked this question in
Q&A
Replies: 2 comments
-
Rich print will perform word wrapping. If you don't want word wrapping, because you're writing to a file, then consider not overriding print for that. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Is there f Be grain control, that is, can I disable it for period of time during the running of the program does it have to be one way the other during the whole program run?? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am writing long lines to a file using print(),
which is intercepted by rich.
When I print to a file, extra line feeds
are added to enforce a carriage size which is sensitive to
that of the shell window from which I invoked the program.
Perhaps there is a hidden variable that I need to set via
an appropriate call?
Here is a minimal example
from rich import print
long_string = 'string_hippopotomonstrosesquipédaliophobie_!@#$%^&*()_+Supercalifragilisticexpialidocious_Antidisestablishmentarianism1234567890123456789'
with open("test.csv", "w") as f:
print(long_string, file=f)
For example, I make the window suitably narrow, I get 3 lines of output, when I expect only 1:
string_hippopotomonstrosesquipédaliophobie_!@#
$%^&*()_+Supercalifragilisticexpialidocious_An
tidisestablishmentarianism1234567890123456789
Beta Was this translation helpful? Give feedback.
All reactions