[Tutor] Printing to file on one line
Clay Shirky
clay at shirky.com
Tue Sep 23 08:44:10 EDT 2003
>> #print header for debits in debits file
>>
>> aba.write('0' + (' ' * 17) + string.zfill(d_batch, 2) + 'MET' + (' ' *
>> 7) + conf_name.ljust(26) + conf_apca[:6] + conf_desc.ljust(12) +
>> str(smdate) + '\r\n')
>> a = '1' + a8f + a9f + ' ' + a3 + a4f + a5f + a6f + a1f + a2f + a10 +
>> '00000000\r\n'
>> aba.write(a)
>> The first write goes over two lines - I want it all on one line:
>>
>> 0 32MET PB Exports 233381Payments
>> 220903^M
See the Control-M (^M) character? That's a line ending. What that suggests
is that python is outputting the line correctly, and your display program
(word processor, telnet window, etc) is line-wrapping the output. Try
looking at the output in a window at least 132 characters wide, instead of
80.
Another way to test this hypothesis would be to reduce your ljust amounts
down from 26 and 12 to something like 2, and/or, reduce the initial
space-padding from 17 as well, to see if the line still wraps.
-clay
More information about the Tutor
mailing list