Expand width of shell in Python's IDLE
Asked Answered
C

1

5

I'm new to python and I'm using Python's IDLE. Using numpy, I created a 24 x 24 matrix. I simply want to look at the matrix. I've maximized the shell on my monitor, so there's plenty of room to print the entire 24 columns' width, but it's only printing the first 13 columns of then continuing onto the next line to print the next 11 columns (had trouble in Stack Overflow copying and pasting what it's doing). The entire right half of the Shell window is blank (it's compressing everything to fit in the left half).

This is harder to read than if it printed 24 columns wide. Can anyone tell me how to convince IDLE to print using the entire width available of the shell (rather than just the left half)? I recognize this is a bit of a stupid question and apologize, but it's driving me crazy.

It looks sort of like this (again, Stack Overflow problems in trying to paste):

[ 0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,
  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.],
[ 0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,
  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.],
[ 0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,
  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.]])

Thanks, Mitch

Chiang answered 14/10, 2011 at 16:24 Comment(2)
Note the icon on the top right of text input box {} for code block. I used thqt to fix (I hope) your formatting issue. (Also manually removed blank lines). Also, I count 63 chars width before line break, (I would expect 80 char). Good luck.Haemocyte
As the answer indicates, the problem is with numpy, not IDLE. With a wide window on my widescreen monitor, print(200*'a') prints a single line of 200 chars with no wrapping. (3.6.1).Handal
T
7

Do

import numpy as np
np.set_printoptions(linewidth=999999)

For more, check

help(np.set_printoptions)
Trolley answered 14/10, 2011 at 22:9 Comment(1)
Exactly. IDLE isn't wrapping lines, but numpy apparently prints it arrays this way by default.Sexology

© 2022 - 2024 — McMap. All rights reserved.