On 25/04/12 16:17, Bala subramanian wrote:

placed depending up on the size of the field. I am thinking to fix the
size of each field.

with open('tmp') as tp:
     for line in tp:
...
         bond.write('   %s\t%s\t%s\t%s\t%s\n' % (p1,p2,p3,p4,new) )

Add your widths to the format string:

         bond.write('   %10s%20s%30s%10s%25s\n' % (p1,p2,p3,p4,new) )

adjust the lengths to suit.

if you write the data in several places you can ensure consistency by defining the format string as a variable:

fmt = '   %10s%20s%30s%10s%25s\n'

bond.write( fmt % (p1,p2,p3,p4,new) )

hth,
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to