Formatting options in Python
Archive - Originally posted on "The Horse's Mouth" - 2013-11-16 17:32:18 - Graham EllisTake a look at this program run:
munchkin:n13py grahamellis$ python twoforms
There is a large piece of timber in the back garden
and the dog was sniffing around it earlier. It looks like it was left
there by the storm that came our way last night.
There is a large piece of plastic tape in the back garden
and the fuzz was sniffing around it earlier. It looks like it was left
there by the graverobber that came our way at Halloween.
munchkin:n13py grahamellis$
I've used two - of many different - possible ways of formatting text in the block above; the program is [here]
Python is a strong text handling language - above example was written on Friday a a demonstration to show a customer how his code could be improved by moving from the first formatting method, where the place holders were a long way from the content ant it was very hard to correlate, to the second format with named place holders.