Printing lists in columns

cjt22 at bath.ac.uk cjt22 at bath.ac.uk
Wed Sep 5 04:07:45 EDT 2007


Thanks guys, I really appreciate it. I have never used google groups
before
and am so impressed with how helpful you all are. It is also lovely
that
none of you mock my little knowledge of Python but just want to
improve it.

I have another question in relation to the izip_longest function (I
persume
this should be within the same topic).
Using this funciton, is there a way to manipulate it so that the
columns can be formated
tabular i.e. perhaps using something such as str(list).rjust(15)
because currently the columns
overlap depending on the strings lengths within each column/list of
lists. i.e. my output is
currently like:

bo, daf, da
pres, ppar, xppc
magnjklep, *, dsa
*, *, nbi

But I want it justified, i.e:

bo       ,  daf,  da
pres     , ppar,  xppc
magnjklep,    *,  dsa
*        ,    *,  nbi

I am struggling to understand how the izip_longest function works
and thus don't really know how it could be manipulated to do the
above.
It would be much apprecited if somoene could also explain how
izip_function
works as I don't like adding code into my programs which I struggle to
understand.
Or perhaps I have to pad out the lists when storing the Strings?

Any help would be much appreciated.




More information about the Python-list mailing list