Re: [Tutor] Is there any standard module for "pretty printing" to stdout?

Magnus Lycka magnus at thinkware.se
Wed Dec 10 18:00:14 EST 2003


> I have a need for tabular and rather fancy printing to stdout. What
> I dream of - would give me control over setting rules on column width, 
> cell padding and/or truncation, justification, etc. Intention is to 
> allow running script connect its hooks into 'tabular thingy 4 fancy 
> printing', run it and let the 'thingy' take care of appying printing 
> rules to the output stream as it happens (as the stream is being 
> genereated).

You might want to have a look at the textwrap module. As I
understand you, you need to write some kind of stream class
that replaces sys.sdtout with your code that uses (maybe)
textwrap, but that's not so difficult. I think there are
examples of roughly that at the ActiveState Python Cookbook.

For really pretty python based printing look at reportlab.com!

-- 
Magnus Lycka, Thinkware AB
Alvans vag 99, SE-907 50 UMEA, SWEDEN
phone: int+46 70 582 80 65, fax: int+46 70 612 80 65
http://www.thinkware.se/  mailto:magnus at thinkware.se



More information about the Tutor mailing list