Disable shell word wrapping

Hey I am printing ascii art which just doesn’t work if it is printed with word wrapping on.
I have looked on the web and no-one seems to have asked, let alone answered the question.
Is it even possible? I can’t believe that such a common language wouldn’t have a word wrapping option…

Even better: if it does exist, is it possible to enable / disable it via. code?

If I understand you want to print without a line end, right?

In python 3 use


In python 2 use


Thanks, but I want to disable the word wrapping when printing a single line.
So if you had a long line of text that goes of the edge of the shell window, it automatically wraps it to a new line instead of going off the page. I want it to go off the page because otherwise the text from ascii art will look really wierd.

That is an OS dependent setting. Are you running on Windows or Linux?

Line wrapping in the interactive shell is not controlled by Python. It
is controlled by your terminal or console.

It is possible that the terminal may have a setting to disable wrapping
at the end of each line, but that would be pretty annoying for most
common uses of the terminal, so I doubt it. (If you are a system
administrator working in a shell, you probably don’t want critical
information from commands being hidden off the side of the terminal.)

If you are writing Python code, you can work out the width of the
terminal and then truncate each line:

from os import get_terminal_size
width = get_terminal_size()[0]
for line in lines:

You might try an advanced shell like Jupiter or IPython, it may have an
option to enable and disable line wrapping, but I doubt it.

Running Windows

OK, thanks.
For python IDLE shell, is there a way to disable text wrapping on that?

That is a non-trivial process so Steven’s suggestion is probably the best choice. However perhaps this article will help.

Thanks for the info.