I would do...
word = ("could" if not condition() else "could not") print "A five ounce bird {0} carry a one pound coconut".format(word)
: R
Edit: for the general case that you want, I would go for composition. For instance. (ok, this is too Go4 and simplified to my liking, but makes a point):
class Agglutinator(list): def __str__(self): return self._separator.join(str(x) for x in self) class Paragraph(Agglutinator): """Returns dot separated sentences""" _separator = '. ' class Sentence(Agglutinator): """Returns comma separated clauses""" _separator = ', ' class Clause(Agglutinator): """Returns space separated words""" _separator = ' ' c1 = Clause(["A", "number", "of", "words", "make", "a", "clause"]) c2 = Clause(["and", "a", "number", "of", "clauses", "make", "a", "sentence"]) c3 = Clause(["A", "collection", "of", "sentences", "makes", "a", "paragraph"]) s1 = Sentence([c1, c2]) s2 = Sentence([c3]) print Paragraph([s1, s2])
which gives you:
A number of words make a clause, and a number of clauses make a sentence. A collection of sentences makes a paragraph
Having developed a bit, you can make Sentence
capitalize the first word, etc.
source share