How do I make pprint do this

J

jcervidae

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.
 
S

skip

I cannot get pprint to format output how I would like. pydb does. I
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.
 
R

Robert Kern

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,954
Messages
2,570,116
Members
46,704
Latest member
BernadineF

Latest Threads

Top