Use StringIO (as ssteiner suggests), cStringIO, or accumulate in a list,
then join together.
CPython now optimizes this one case of accumulating strings so that it's
not quadratic in performance. Naively, it is an optimization that we
should be able to do too once we have a smarter compiler (the SSA work),
although it may not be a high priority.

No smarter compiler forthcoming for this type of work (the SSA work didn't pan out). CPython can do certain types of local optimizations around loops that are not possible under the GC model used by Java and consequently Jython.