[Tutor] formatting sql output
Stephanie Jones
ss_jones@hotmail.com
Mon, 03 May 1999 14:49:16 PDT
I am currently trying to format the output of a sql query using the
techniques described in the book "Internet Programming with Python" under
the subsection "Building an ASCII Table Generator" (pp 65-66).
Basically, the result of the query is a tuple called "opened". I then have,
following the example in the book:
for x in opened:
list=[x[0],x[2],x[3],x[1]]
printstring=formatfields(list)
print printstring
def formatfields(list):
fieldsformatted=map(fieldformat15,list)
return string.joinfields(fieldsformatted, " | ")
def fieldformat15(field):
return '%-15s' % field
However, it doesn't seem to be formatting so that each "field" is 15
characters long. Does my question make sense, and does anyone have an idea
why it is doing this?
_______________________________________________________________
Get Free Email and Do More On The Web. Visit http://www.msn.com