Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > How do I make pprint do this

Reply
Thread Tools

How do I make pprint do this

 
 
jcervidae
Guest
Posts: n/a
 
      05-20-2009
I cannot get pprint to format output how I would like. pydb does. I
tried grepping the source but still couldn't grok it. Here:

(Pydb) a = range(1,100)
(Pydb) pp a
[1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10, 11, 12, 13, 14, 15, 16, 17,
18, 19, 20
21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
38, 39, 40
41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,
58, 59, 60
61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
78, 79...]

It puts multiple elements on the same line. I can't work out how to
make it do that.
 
Reply With Quote
 
 
 
 
skip@pobox.com
Guest
Posts: n/a
 
      05-20-2009
>> I cannot get pprint to format output how I would like. pydb does. I
>> tried grepping the source but still couldn't grok it.


That's not the way pprint works. You have no control over how it arranges
its output. If you need something more flexible you'll have to roll your
own.

--
Skip Montanaro - http://www.velocityreviews.com/forums/(E-Mail Removed) - http://www.smontanaro.net/
America's vaunted "free press" notwithstanding, story ideas that expose
the unseemly side of actual or potential advertisers tend to fall by the
wayside. Not quite sure why. -- Jim Thornton
 
Reply With Quote
 
 
 
 
Robert Kern
Guest
Posts: n/a
 
      05-20-2009
On 2009-05-20 10:37, (E-Mail Removed) wrote:
> >> I cannot get pprint to format output how I would like. pydb does. I
> >> tried grepping the source but still couldn't grok it.

>
> That's not the way pprint works. You have no control over how it arranges
> its output. If you need something more flexible you'll have to roll your
> own.


Or use Armin Ronacher's excellent pretty.py:

http://dev.pocoo.org/hg/sandbox/file/tip/pretty

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Re: pprint, __repr__ and inheritance, how does it works? Gabriel Genellina Python 0 02-26-2008 06:57 AM
pprint, __repr__ and inheritance, how does it works? Jorge Vargas Python 0 02-25-2008 12:19 PM
pprint: "...thank small children who sleep at night." Brian L. Troutwine Python 6 09-20-2006 03:05 PM
any plans to make pprint() a builtin? John Salerno Python 9 05-17-2006 01:47 AM



Advertisments