I wanted to make a nice, pretty text file from some log info, but python didn't want to cooperate with string formatting.
I was trying something like this:
f=open('file','w')
f.write('%-10s' %string)
At the interactive prompt, the equivalent print command would give the desired result.
I got it to work by replacing f.write() with
print >> f, mystring.ljust(10)
This code has the same net result of printing to the file, but it actually does the spacing properly.
This thread gave me the hint I needed, though it looks like the poor guy never resolved his issue - he should have tried the print suggestion.
http://bytes.com/groups/python/25205-using-string-ljust-try-hold-fixed-width#links
1. Copy and paste answers from Wikipedia. Don't bother paraphrasing them - leave them in their (somewhat) good English, so that they're easy to pick up as plagiarized. Better yet, leave the blue text and active hyperlinks. Then justify it by saying the information was hard to find.
2. Treat your elder as the group secretary. He doesn't get enough of this shit from the boss, and he looked lonely. Ask him to find you a desk, or better yet, make space for you.
3. Declare that it's the TA's fault that you don't have a good sample to work with for lab. Demand that he provide a better one for next time. Ignore that other classmates got good results from the same sample, just a different region.
4. Do all of the above with charming enthusiasm and smiley faces.