On Mon, 2 Jun 2008 12:42:12 -0700 (PDT), Mensanator <[EMAIL PROTECTED]> wrote: > On Jun 2, 3:38 am, Chris <[EMAIL PROTECTED]> wrote: > > On Jun 2, 9:34 am, "[EMAIL PROTECTED]" > > > > <[EMAIL PROTECTED]> wrote: > > > Hi, > > > > > i am building a little script and i want to output a series of columns > > > more or less like this: > > > > > 1 5 6 > > > 2 2 8 > > > 2 9 5 > ...
I have a related question: Does Python have (or can emulate) the formatted output capability found in Perl? For example, all I have to do to get nicely formatted (i.e., aligned) output is provide values for special STDOUT variables (i.e., STDOUT_TOP, STDOUT, STDOUT_BOTTOM, etc.), exemplified by: format STDOUT_TOP = ------------------------------------------------------------------------------ ~ . format STDOUT = @<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<< $res->{'full_name'}, $res->{'phone_1'}, $res->{'phone_1_type'} @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ~ $res->{'address_1a'}, $res->{'address_2a'} @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ~ $res->{'address_1b'}, $res->{'address_2b'} @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ~ $res->{'address_1c'}, $res->{'address_2c'} @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ~ $city_1 $city_2 @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ~ $res->{'email_1'}, $res->{'email_2'} ------------------------------------------------------------------------------ ~ . Then, all I have to do is populate my $res object/hash as desired -- in this example simple the results of a SQL query -- and lastly just call the "write" function: write; and Perl will produce very nicely formatted results. This is useful not only for producing human readable output, but also fixed-column-width data files, etc. I'd love to learn the Pythonistic way of doing the same thing. Thanks! Doug -- http://mail.python.org/mailman/listinfo/python-list