[Tutor] interesting behaviour with postional output

Cranky Frankie cranky.frankie at gmail.com
Mon Nov 14 19:58:54 CET 2011

I'm working on writing out postional output. When I use this statement:

print('%-40s%s' % (element_list[0], element_list[1]))	

I get nice, lined up columns on the screen. When I write to a file like this:

new_line = ('%-40s%s%s' % (element_list[0], element_list[1],'\n'))

a very funny thing happens. When I open the file in Notepad, the
columns are not lined up, however when I switch the font to Courier,
they * are* lined up. So what's happening is the output statement is
working correctly - the second column starts in the 41st postion - but
you have to use a non-proportional font to see it.

I was hoping to not have the font be an issue.

Very interesting.

Frank L. "Cranky Frankie" Palmeri, Guilderland, NY, USA
             Risible Riding Raconteur & Writer
Don't sweat the petty things, and don't pet the sweaty things.

More information about the Tutor mailing list