ActivePython word wrap in Shell or PythonWin during list printout
Rufus V. Smith
nospam at nospam
Wed Jul 11 23:40:48 CEST 2001
I am running the latest Python from ActiveState and I have a
problem that when I print a long list (Like dir()), the entire list
prints out on one line and I have to scroll over to read it.
Is there an environment setting to force word wrap at
a certain line length?
Or is there a list function that can take a list and
pretty print it with word wrap.
(Not having one gave me an opportunity to learn
some Python scripting as I wrote my own, but
if there was a library standard, that might be better. )
for a in L:
if len(str(a)+b)+3 >= margin :
b = "'"+str(a)+"'"
if b: b+=","
b += "'"+str(a)+"'"
if b: print b
With this function, I just type marginprint(dir())
and it will respect the margins.
Only I have to load this into my environment every time
I bring it up.
More information about the Python-list