# Disable shell word wrapping

**URL:** <https://discuss.python.org/t/disable-shell-word-wrapping/4297>\
**Category:** Python Help\
**Created:** [May 29, 2020, 4:29pm UTC](https://discuss.python.org/t/disable-shell-word-wrapping/4297 "2020-05-29T16:29:13Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![biran4454](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/biran4454/32/2265_2.png) [@biran4454](https://discuss.python.org/u/biran4454)\
**Post date:** [May 29, 2020, 4:29pm UTC](https://discuss.python.org/t/disable-shell-word-wrapping/4297/1 "2020-05-29T16:29:13Z")

</div>

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?  
Thanks!

---

<div class="post-metadata">

**Author:** ![gw1500se1](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/gw1500se1/32/2155_2.png) [@gw1500se1](https://discuss.python.org/u/gw1500se1)\
**Post date:** [May 29, 2020, 7:01pm UTC](https://discuss.python.org/t/disable-shell-word-wrapping/4297/2 "2020-05-29T19:01:08Z")

</div>

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

In python 3 use

```
print(somestring,end='')

```

In python 2 use

```
sys.stdout.write(somestring)
```

---

<div class="post-metadata">

**Author:** ![biran4454](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/biran4454/32/2265_2.png) [@biran4454](https://discuss.python.org/u/biran4454)\
**Post date:** [May 29, 2020, 7:51pm UTC](https://discuss.python.org/t/disable-shell-word-wrapping/4297/3 "2020-05-29T19:51:52Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![gw1500se1](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/gw1500se1/32/2155_2.png) [@gw1500se1](https://discuss.python.org/u/gw1500se1)\
**Post date:** [May 29, 2020, 9:19pm UTC](https://discuss.python.org/t/disable-shell-word-wrapping/4297/4 "2020-05-29T21:19:26Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![steven.daprano](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/steven.daprano/32/1083_2.png) [@steven.daprano](https://discuss.python.org/u/steven.daprano)\
**Post date:** [May 30, 2020, 6:15am UTC](https://discuss.python.org/t/disable-shell-word-wrapping/4297/5 "2020-05-30T06:15:23Z")

</div>

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:
    print(line[:width])

```

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.

---

<div class="post-metadata">

**Author:** ![biran4454](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/biran4454/32/2265_2.png) [@biran4454](https://discuss.python.org/u/biran4454)\
**Post date:** [May 30, 2020, 9:34am UTC](https://discuss.python.org/t/disable-shell-word-wrapping/4297/6 "2020-05-30T09:34:31Z")

</div>

Running Windows

---

<div class="post-metadata">

**Author:** ![biran4454](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/biran4454/32/2265_2.png) [@biran4454](https://discuss.python.org/u/biran4454)\
**Post date:** [May 30, 2020, 9:36am UTC](https://discuss.python.org/t/disable-shell-word-wrapping/4297/7 "2020-05-30T09:36:30Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![gw1500se1](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/gw1500se1/32/2155_2.png) [@gw1500se1](https://discuss.python.org/u/gw1500se1)\
**Post date:** [May 30, 2020, 1:31pm UTC](https://discuss.python.org/t/disable-shell-word-wrapping/4297/8 "2020-05-30T13:31:43Z")

</div>

That is a non-trivial process so Steven’s suggestion is probably the best choice. However perhaps [this article](https://social.technet.microsoft.com/wiki/contents/articles/20555.how-to-write-to-a-console-window-without-wrapping-text.aspx) will help.

---

<div class="post-metadata">

**Author:** ![biran4454](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/biran4454/32/2265_2.png) [@biran4454](https://discuss.python.org/u/biran4454)\
**Post date:** [May 30, 2020, 5:31pm UTC](https://discuss.python.org/t/disable-shell-word-wrapping/4297/9 "2020-05-30T17:31:11Z")

</div>

Thanks for the info.
