StringIO in 2.6 and beyond
Bill McClain
20080915.20.wmcclain at spamgourmet.com
Wed Dec 10 13:55:10 EST 2008
On 2008-12-10, pruebauno at latinmail.com <pruebauno at latinmail.com> wrote:
> I think this combination might do the trick (I don't have 2.6 to test
> it right now):
> from __future__ import print_function
> from __future__ import unicode_literals
> from functools import partial
> import io
> print = partial(print, sep=" ", end="\n")
> out = io.StringIO()
> print("hello", file=out)
The example works, but unicode_literals causes problems elsewhere, in optparse
for example. I didn't look into it too closely. I'll probably give up trying
to anticipate 3.0 with 2.6 too closely.
-Bill
--
Sattre Press Tales of War
http://sattre-press.com/ by Lord Dunsany
info at sattre-press.com http://sattre-press.com/tow.html
More information about the Python-list
mailing list