ascii tables

Tom Verbeure tom_verbeure at hot.nospam.mail.com
Mon Jun 2 18:03:16 EDT 2003


"Bengt Richter" <bokr at oz.net> schreef in bericht
news:bbg6kb$dif$0 at 216.39.172.122...
> On Fri, 30 May 2003 00:37:46 +0200, Carel Fellinger
<carel.fellinger at chello.nl> wrote:
>
> >On Thu, May 29, 2003 at 02:01:47PM -0500, John Hunter wrote:
> >...
> >> Here is my first pass at a solution, which prints
> >>
> >>     Name   | Age | Sex | Weight | Height
> >>     ------------------------------------
> >>     John   |  35 |  M  |  170.0 |   60.1
> >>     ------------------------------------
> >>     Miriam |  31 |  F  |  135.0 |   58.2
> >>     ------------------------------------
> >>     Rahel  |   5 |  F  |   40.0 |   48.2
> >>     ------------------------------------
> >>     Ava    |   2 |  F  |   25.0 |   30.0
> >
> >it's old printer wisdom that one should be very reluctant to use lines
> >in tables, and indeed I find the following much easier on the eyes:
> >
> >    Name   : Age : Sex : Weight : Height
> >    ------------------------------------
> >    John      35    M     170.0     60.1
> >    Miriam    31    F     135.0     58.2
> >    Rahel      5    F      40.0     48.2
> >    Ava        2    F      25.0     30.0
> >
> Agreed, but IMO this boxed format is not too bad
> an alternative (and if you have a font with box
> characters it can look pretty nice).
>
>    +--------+-----+-----+--------+--------+
>    | Name   | Age | Sex | Weight | Height |
>    +--------+-----+-----+--------+--------+
>    | John   |  35 |  M  |  170.0 |   60.1 |
>    | Miriam |  31 |  F  |  135.0 |   58.2 |
>    | Rahel  |   5 |  F  |   40.0 |   48.2 |
>    | Ava    |   2 |  F  |   25.0 |   30.0 |
>    +--------+-----+-----+--------+--------+
>
> >use atleast 3 spaces to seperate columns and you won't need that ugly
bar.
> >
> >
> >...
> >>     def pad_entry(entry, align, width):
> >
> >you could also use str's center, ljust and rjust methods.
> >
> >
>
> Regards,
> Bengt Richter






More information about the Python-list mailing list